Exemple #1
0
        public ActionResult Edit(Models.Cinema cinema)
        {
            if (ModelState.IsValid)
            {
                var dbCinema = new Domain.Cinema();
                dbCinema.InjectFrom(cinema);
                cinemaRepository.Update(dbCinema);
                TempData["message"] = string.Format("{0} has been saved", cinema.CinemaCity);
                unitOfWork.Commit();
            }
            else
            {
                return(View(cinema));
            }

            return(RedirectToAction("Index"));
        }
Exemple #2
0
        public ActionResult Create(Models.Cinema model)
        {
            if (ModelState.IsValid)
            {
                if (!cinemaService.ExistsCinema(model.CinemaCity))
                {
                    var dbModel = new Domain.Cinema();
                    dbModel.InjectFrom(model);
                    cinemaService.AddCinema(dbModel);
                    TempData["message"] = string.Format("{0} has been saved", model.CinemaCity);
                }
                else
                {
                    ModelState.AddModelError("CinemaCity", "Cant add a cinema that is already in the database!");

                    //transform the object
                    //unitOfWork.Commit
                    return(View(model));
                }
                return(RedirectToAction("Index"));
            }
            return(View(model));
        }