using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using WebGridExample.Models;
using WebGridExample.Repository;

namespace WebGridExample.Controllers
{
    public class HomeController : Controller
    {
        public ActionResult Index()
        {
            return View();
        }

        public ActionResult GridDefault()
        {
            var repository = new SamochodRepository();
            var model = repository.GetAll();
            return View(model);
        }

        public ActionResult GridRepositoryPagingAndSorting(int page = 1, string sort = "ID", string sortDir = "ASC")
        {
            const int pageSize = 5;
            var repository = new SamochodRepository();

            var model = new SamochodPresentationModel
            {
                PageSize = pageSize,
                PageNumber = page,
                Items = repository.GetPage(page, pageSize, sort, sortDir),
                TotalRows = repository.GetTotalRowCount()
            };

            return View(model);
        }

        public ActionResult GridWithFeatures()
        {
            var repository = new SamochodRepository();
            var model = repository.GetAll();
            return View(model);
        }
    
    }
}
