using DetailGrids.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace DetailGrids.Controllers
{
    public class HomeController : Controller
    {
        public ActionResult Index()
        {
            var result = Enumerable.Range(0, 50).Select(i => new Inventory
            {
                ItemCode = "ItemCode" + i,
                Allocated = i * 10,
                Description = "Description " + i,
                CT_WHSE_1 = i * 5,
                CT_WHSE_2 = i * 6,
                DE_WHSE = i * 11,
                LastPO = "LastPO " + i,
                LastPOUnit = i,
                UnitCost = i * 12,
                UOM = "UOM " + i,
                LastReceiptDate = new DateTime().AddDays(i),
                Orders = Enumerable.Range(0, 50).Select(m => new OrderViewModel
                {
                    OrderID = m,
                    Freight = i * 10,
                    OrderDate = DateTime.Now.AddDays(i),
                    ShipName = "ShipName " + i,
                    ShipCity = "ShipCity " + i
                }).ToList()
            });

            return View(result);
        }

        public ActionResult About()
        {
            ViewBag.Message = "Your app description page.";
            var result = Enumerable.Range(0, 5).Select(i => new InventoryDetail
            {
                ItemCode = "ItemCode" + i,
                Allocated = i * 10,
                Bin = "Bin " + i * 5,
                OnHand = i * 7,
                OnOrder = i * 2,
                Warehouse = "Warehouse " + i

            });

            return Json(result, JsonRequestBehavior.AllowGet);
        }

        public ActionResult Contact()
        {
            ViewBag.Message = "Your contact page.";

            return View();
        }
    }
}
