public ViewResult AddItems()
        {
            InventoryModel Inv2 = new InventoryModel();

            List<InventoryModel> Inv = (List<InventoryModel>)HttpContext.Application["MyList"];
            int count = 0;

            foreach (var List in (List<InventoryModel>)HttpContext.Application["MyList"])
            {
                if (List.ID > count)
                {
                    count = List.ID;
                }
            }
            count++;

            Inv2.ID = count;

            if (HttpContext.Application["MyCategoryList"] != null)
            {
                List<String> categorylist = (List<String>)HttpContext.Application["MyCategoryList"];
                List<SelectListItem> select = new List<SelectListItem>();
                foreach (var list in categorylist)
                {
                    select.Add(new SelectListItem() { Value = list, Text = list });
                }
                ViewBag.MyCategoryList = categorylist;
            }
            else
            {
                ViewBag.MyCategoryList = new List<String>();
            }

            return View(Inv2);
        }
Exemplo n.º 2
0
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            List<InventoryModel> Equipments = new List<InventoryModel>();
            InventoryModel Eq1 = new InventoryModel
            {
                ID = 1,
                Code = "C0001",
                Category = "Laptop",
                Description = "Powerful. Sleek. Light. Affordable ",
                Name = "Lenovo"
            };

            InventoryModel Eq2 = new InventoryModel
            {
                ID = 2,
                Code = "C0002",
                Category = "Computer",
                Description = " Big! Light! ",
                Name = "Mac Desktop "
            };

            InventoryModel Eq3 = new InventoryModel
            {
                ID = 3,
                Code = "P0003",
                Category = "Printer ",
                Description = " Fast printer, WiFi, copy! ",
                Name = "MNV Printer"
            };

            Equipments.Add(Eq1);
            Equipments.Add(Eq2);
            Equipments.Add(Eq3);

            Application["MyList"] = Equipments;

            List<string> CatList = new List<string>();
            CatList.Add("Printer");
            CatList.Add("Laptop");
            CatList.Add("Computer");

            Application["MyCategoryList"] = CatList;
        }
        public ViewResult AddItems(InventoryModel inventory)
        {
            List<string>  category = (List<String>)HttpContext.Application["MyCategoryList"];

            ViewBag.MyCategoryList = category;

            if (ModelState.IsValid)
               {

               List<InventoryModel> Inv = (List<InventoryModel>)HttpContext.Application["MyList"];
                Inv.Add(inventory);
               ViewBag.MyList = Inv;

                 return View("Index");

            }

            else

               return View(inventory);
        }
        public ActionResult ComputerIndex()
        {
            List<InventoryModel> Desktop = new List<InventoryModel>();
            InventoryModel Eq1 = new InventoryModel
            {
                ID = 2,
                Code = "C0002",
                Name = "Desktop Computer",
                Description = "Dell Inspiron 3000 i3646-2600BLK Desktop Computer ",
            };

            Desktop.Add(Eq1);

            return View(Desktop);
        }
        public ActionResult PrinterIndex()
        {
            List<InventoryModel> Printers = new List<InventoryModel>();
            InventoryModel Eq1 = new InventoryModel
            {
                ID = 3,
                Code = "P0003",
                Name = "Printers",
                Description = "Xerox WorkCentre 3215/NI Wireless Mono Laser Multifunction ",
            };

            Printers.Add(Eq1);

            return View(Printers);
        }
        public ActionResult LaptopIndex()
        {
            List<InventoryModel> Laptops = new List<InventoryModel>();
            InventoryModel Eq1 = new InventoryModel
            {
                ID = 1,
                Code = "C0001",
                Name = "Laptop Computer",
                Description = "Dell XPS 13 Laptop",
            };

            Laptops.Add(Eq1);

            return View(Laptops);
        }