Beispiel #1
0
        public ActionResult Edit(int ID)
        {
            var service = CreateTheaterProductionService();
            var detail  = service.GetTheaterProductionByID(ID);
            var model   =
                new TheaterProductionEdit
            {
                TheaterProductionID = detail.TheaterProductionID,
                Title         = detail.Title,
                MainCast      = detail.MainCast,
                Description   = detail.Description,
                YearReleased  = detail.YearReleased,
                DateWatched   = detail.DateWatched,
                IsRecommended = detail.IsRecommended,
                ModifiedUtc   = DateTimeOffset.UtcNow
            };

            return(View(model));
        }
        public bool UpdateTheaterProduction(TheaterProductionEdit model)
        {
            using (var ctx = new ApplicationDbContext())
            {
                var entity =
                    ctx
                    .TheaterProductions
                    .Single(e => e.TheaterProductionID == model.TheaterProductionID);    // && e.OwnerID == _userID);//This is Linq

                entity.TheaterProductionID = model.TheaterProductionID;
                entity.Title         = model.Title;
                entity.MainCast      = model.MainCast;
                entity.Description   = model.Description;
                entity.YearReleased  = model.YearReleased;
                entity.DateWatched   = model.DateWatched;
                entity.IsRecommended = model.IsRecommended;
                entity.ModifiedUtc   = DateTimeOffset.UtcNow;

                return(ctx.SaveChanges() == 1);
            }
        }
Beispiel #3
0
        public ActionResult Edit(int ID, TheaterProductionEdit model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

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

            var service = CreateTheaterProductionService();

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

            ModelState.AddModelError("", "Your theater production could not be updated.");
            return(View(model));
        }