Ejemplo n.º 1
0
        // GET: MOBA/Edit/5
        public ActionResult Edit(int id)
        {
            var service = new MOBAService();
            var detail  = service.GetMOBAById(id);
            var model   = new MOBAEdit
            {
                MotherboardId      = detail.MotherboardId,
                Name               = detail.Name,
                Manufacturer       = detail.Manufacturer,
                Socket             = detail.Socket,
                FormFactor         = detail.FormFactor,
                MemoryMax          = detail.MemoryMax,
                MemorySlots        = detail.MemorySlots,
                Color              = detail.Color,
                Chipset            = detail.Chipset,
                PCIEX16Slots       = detail.PCIEX16Slots,
                PCIEX8Slots        = detail.PCIEX8Slots,
                PCIEX4Slots        = detail.PCIEX4Slots,
                PCISlots           = detail.PCISlots,
                EthernetPorts      = detail.EthernetPorts,
                M2Slots            = detail.M2Slots,
                Sata3GBsPorts      = detail.Sata3GBsPorts,
                Sata6GBsPorts      = detail.Sata6GBsPorts,
                SataExpressPorts   = detail.MSataSlots,
                OnboardVideo       = detail.OnboardVideo,
                OnboardUSB3Headers = detail.OnboardUSB3Headers,
                WifiNetworking     = detail.WifiNetworking,
                IsAvailable        = detail.IsAvailable,
            };

            return(View(model));
        }
Ejemplo n.º 2
0
        public bool UpdateMOBA(MOBAEdit model)
        {
            using (var _db = new ApplicationDbContext())
            {
                var MOBAEntity =
                    _db
                    .Motherboards
                    .SingleOrDefault(e => e.MotherboardId == model.MotherboardId);
                MOBAEntity.Name               = model.Name;
                MOBAEntity.Manufacturer       = model.Manufacturer;
                MOBAEntity.Color              = model.Color;
                MOBAEntity.Socket             = model.Socket;
                MOBAEntity.FormFactor         = model.FormFactor;
                MOBAEntity.MemoryMax          = model.MemoryMax;
                MOBAEntity.MemorySlots        = model.MemorySlots;
                MOBAEntity.Chipset            = model.Chipset;
                MOBAEntity.PCIEX16Slots       = model.PCIEX16Slots;
                MOBAEntity.PCIEX8Slots        = model.PCIEX8Slots;
                MOBAEntity.PCIEX4Slots        = model.PCIEX4Slots;
                MOBAEntity.PCISlots           = model.PCISlots;
                MOBAEntity.EthernetPorts      = model.EthernetPorts;
                MOBAEntity.M2Slots            = model.M2Slots;
                MOBAEntity.Sata3GBsPorts      = model.Sata3GBsPorts;
                MOBAEntity.Sata6GBsPorts      = model.Sata6GBsPorts;
                MOBAEntity.SataExpressPorts   = model.SataExpressPorts;
                MOBAEntity.MSataSlots         = model.MSataSlots;
                MOBAEntity.OnboardVideo       = model.OnboardVideo;
                MOBAEntity.OnboardUSB3Headers = model.OnboardUSB3Headers;
                MOBAEntity.WifiNetworking     = model.WifiNetworking;
                MOBAEntity.IsAvailable        = model.IsAvailable;

                return(_db.SaveChanges() == 1);
            }
        }
Ejemplo n.º 3
0
        public ActionResult Edit(int id, MOBAEdit model)
        {
            if (model.MotherboardId != id)
            {
                ModelState.AddModelError("", "Id Mismatch");
                return(View(model));
            }

            var service = new MOBAService();

            if (service.UpdateMOBA(model))
            {
                TempData["SaveResult"] = "Your Motherboard information was updated.";
                return(RedirectToAction("Index"));
            }

            ModelState.AddModelError("", "Your Motherboard information could not be updated.");
            return(View());
        }