using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Ajax2.Models.Repositories;
using Ajax2.Models.Entities;

namespace Ajax2.Controllers
{
    public class DefaultController : Controller
    {
        //
        // GET: /Default/

        public ActionResult Index(string query)
        {
            var model = OsobaRepository.GetOsobas().Where(e => query == null || e.Nazwisko.StartsWith(query)).OrderBy(m => m.Nazwisko).ToList();
            if (Request.IsAjaxRequest())
            {
                return PartialView("~/Views/Shared/_ListaOsob.cshtml", model);
            }
            return View(model);
        }
    }
}
