public bool UpdatePlatform(PlatformEdit model)
        {
            using (var ctx = new ApplicationDbContext())
            {
                var entity =
                    ctx.Platforms.Find(model.PlatformID);

                entity.Brand        = model.Brand;
                entity.PlatformName = model.PlatformName;
                entity.ReleaseDate  = model.ReleaseDate;

                return(ctx.SaveChanges() == 1);
            }
        }
        // GET: Edit
        public ActionResult Edit(int id)
        {
            var svc     = CreatePlatformService();
            var details = svc.GetPlatformByID(id);
            var model   = new PlatformEdit
            {
                PlatformID   = details.PlatformID,
                Brand        = details.Brand,
                PlatformName = details.PlatformName,
                ReleaseDate  = details.ReleaseDate
            };

            return(View(model));
        }
Exemple #3
0
        public bool UpdatePlatform(PlatformEdit model)
        {
            using (var ctx = new ApplicationDbContext())
            {
                var entity =
                    ctx
                    .Platforms
                    .Single(e => e.PlatformId == model.PlatformId);
                entity.Title        = model.Title;
                entity.Description  = model.Description;
                entity.Manufacturor = model.Manufacturor;
                entity.ReleaseYear  = model.ReleaseYear;

                return(ctx.SaveChanges() == 1);
            }
        }
Exemple #4
0
        public ActionResult Edit(int id)
        {
            var service = CreatePlatformService();
            var detail  = service.GetPlatformById(id);
            var model   =
                new PlatformEdit
            {
                PlatformId   = detail.PlatformId,
                Title        = detail.Title,
                Description  = detail.Description,
                Manufacturor = detail.Manufacturor,
                ReleaseYear  = detail.ReleaseYear
            };

            return(View(model));
        }
Exemple #5
0
        public ActionResult Edit(int id, PlatformEdit model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            if (model.PlatformId != id)
            {
                ModelState.AddModelError("", "Id Mismatch");
                return(View(model));
            }

            var service = CreatePlatformService();

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

            ModelState.AddModelError("", "Your game could not be updated.");
            return(View(model));
        }
        public ActionResult Edit(int id, PlatformEdit model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            if (model.PlatformID != id)
            {
                ModelState.AddModelError("", "ID mismatch");
                return(View(model));
            }

            var svc = CreatePlatformService();

            if (svc.UpdatePlatform(model))
            {
                TempData["SaveResult"] = "Platform info was successfully updated!";
                return(RedirectToAction("Index"));
            }

            ModelState.AddModelError("", "An error occurred while attempting to update the platform info - changes not saved.");
            return(View(model));
        }