Пример #1
0
        public ActionResult Edit(int id)
        {
            var service = CreateTheaterService();
            var detail  = service.GetTheaterById(id);
            var model   =
                new TheaterEdit
            {
                TheaterId       = detail.TheaterId,
                TheaterName     = detail.TheaterName,
                TheaterLocation = detail.TheaterLocation,
            };

            return(View(model));
        }
Пример #2
0
        public bool UpdateTheater(TheaterEdit model)
        {
            using (var ctx = new ApplicationDbContext())
            {
                var entity =
                    ctx
                    .Theater
                    .Single(e => e.TheaterId == model.TheaterId && e.OwnerId == _userId);

                entity.TheaterName     = model.TheaterName;
                entity.TheaterLocation = model.TheaterLocation;
                entity.ModifiedUtc     = DateTimeOffset.UtcNow;

                return(ctx.SaveChanges() == 1);
            }
        }
Пример #3
0
        public ActionResult Edit(int id, TheaterEdit model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

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

            var service = CreateTheaterService();

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

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