
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Text;
using System.Web;
using System.Web.Mvc;

namespace Test
{
    public class ProductController : Controller
    {
        public ActionResult Index()
        {
            return View();
        }

        [HttpPost]
        public JsonResult Add(List<dtoBaseProduct> models)
        {
            return Json(models[0], JsonRequestBehavior.AllowGet);
        }

        [HttpPost]
        public JsonResult Update(List<dtoBaseProduct> models)
        {
            //Save tenant to DB
            return Json(models[0], JsonRequestBehavior.AllowGet);
        }

        [HttpPost]
        public JsonResult Delete(List<dtoBaseProduct> models)
        {
            return ProductList();
        }

        public JsonResult ProductList(bool IncludeInternal = false)
        {
            List<dtoBaseProduct> list = new List<dtoBaseProduct>();
            Guid productID = Guid.NewGuid();
            dtoBaseProduct p = new dtoBaseProduct()
            {
                Cnt = 0,
                Created = DateTime.Now,
                Description = "Product 1",
                IsInternal = false,
                LastModified = DateTime.Now,
                LogonURL = null,
                ProductID = productID,
                ProductName = "Product 1"
            };
            list.Add(p);
            return Json(list, JsonRequestBehavior.AllowGet);
        }

        public JsonResult AutoCompleteProductList(string ProdName)
        {
            return Json(ProductList(), JsonRequestBehavior.AllowGet);
        }
    }
}
