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

namespace BoundPanelbar.Controllers
{
    public class HomeController : Controller
    {
        public ActionResult Index()
        {
            var model = new CategoryView();
            model.Categories = new List<Category>();
            model.Categories.Add(new Category() { CategoryName = "Chairs", Id = 1, Url = Url.Action("Products", new { categoryId = 1 }) });
            model.Categories.Add(new Category() { CategoryName = "Desks", Id = 2, Url = Url.Action("Products", new { categoryId = 2 }) });
            model.Categories.Add(new Category() { CategoryName = "Lights", Id = 3, Url = Url.Action("Products", new { categoryId = 3 }) });

            return View(model);
        }

        public PartialViewResult Products(int categoryId)
        {
            var model = new ProductsView();
            model.PanelId = string.Format("ProductCategory-{0}", categoryId);
            model.Products = new List<Product>();
            switch (categoryId)
            {
                case 1:
                    model.Products.Add(new Product() { ProductName = "Chair 1", Id = 1 });
                    model.Products.Add(new Product() { ProductName = "Chair 2", Id = 2 });
                    model.Products.Add(new Product() { ProductName = "Chair 3", Id = 3 });
                    break;
                case 2:
                    model.Products.Add(new Product() { ProductName = "Desk 1", Id = 10 });
                    model.Products.Add(new Product() { ProductName = "Desk 2", Id = 20 });
                    model.Products.Add(new Product() { ProductName = "Desk 3", Id = 30 });
                    break;
                case 3:
                    model.Products.Add(new Product() { ProductName = "Light 1", Id = 11 });
                    model.Products.Add(new Product() { ProductName = "Light 2", Id = 21 });
                    model.Products.Add(new Product() { ProductName = "Light 3", Id = 31 });
                    break;
            }

            return PartialView(model);
        }
    }
}
