Exemple #1
0
        public ActionResult NewCarryingBag(CarryingBag carryingBag)
        {
            if (!ModelState.IsValid)
            {
                return(View("CarryingBagForm", carryingBag));
            }

            if (carryingBag.Id == 0)
            {
                _context.Items.Add(carryingBag);
            }
            else
            {
                var carryingBagInDb = _context.Items.OfType <CarryingBag>().Single(m => m.Id == carryingBag.Id);

                carryingBagInDb.Name                 = carryingBag.Name;
                carryingBagInDb.Price                = carryingBag.Price;
                carryingBagInDb.SKU                  = carryingBag.SKU;
                carryingBagInDb.Warranty             = carryingBag.Warranty;
                carryingBagInDb.Model                = carryingBag.Model;
                carryingBagInDb.Company              = carryingBag.Company;
                carryingBagInDb.AccessoryDescription = carryingBag.AccessoryDescription;
                carryingBagInDb.BagColor             = carryingBag.BagColor;
                carryingBagInDb.BagSize              = carryingBag.BagSize;
                carryingBagInDb.BagType              = carryingBag.BagType;
            }

            _context.SaveChanges();

            return(View("ItemForm"));
        }
Exemple #2
0
        public ActionResult New(string typeId)
        {
            if (typeId == "Default")
            {
                return(View("ItemForm"));
            }

            if (typeId == "Desktop")
            {
                Desktop desktop = new Desktop();
                return(View("DesktopForm", desktop));
            }

            if (typeId == "Camera")
            {
                Camera camera = new Camera();
                return(View("CameraForm", camera));
            }

            if (typeId == "CarryingBag")
            {
                CarryingBag carryingBag = new CarryingBag();
                return(View("CarryingBagForm", carryingBag));
            }

            if (typeId == "GameConsole")
            {
                GameConsole gameConsole = new GameConsole();
                return(View("GameConsoleForm", gameConsole));
            }

            if (typeId == "Laptop")
            {
                Laptop laptop = new Laptop();
                return(View("LaptopForm", laptop));
            }

            if (typeId == "MajorAppliance")
            {
                MajorAppliance majorAppliance = new MajorAppliance();
                return(View("MajorApplianceForm", majorAppliance));
            }

            if (typeId == "MouseAndKeyBoard")
            {
                MouseAndKeyBoard mouseAndKeyBoard = new MouseAndKeyBoard();
                return(View("MouseAndKeyBoardForm", mouseAndKeyBoard));
            }

            if (typeId == "Movie")
            {
                Movie movie = new Movie();
                return(View("MovieForm", movie));
            }

            if (typeId == "Software")
            {
                Software software = new Software();
                return(View("SoftwareForm", software));
            }

            if (typeId == "VideoGame")
            {
                VideoGame videoGame = new VideoGame();
                return(View("VideoGameForm", videoGame));
            }


            return(View("ItemForm"));
        }