예제 #1
0
        public ActionResult AddOrEditFilm(int? filmid)
        {
            var film = new Film();
            if (filmid.HasValue)
            {

                film = db.Films.SingleOrDefault(x => x.Id == filmid.Value);
            }
            return View(film);
        }
예제 #2
0
        public ActionResult AddOrEditFilm(Film film)
        {
            if (ModelState.IsValid)
            {
                //if (film.OrderStart >= film.OrderEnd)
                //{
                //    ModelState.AddModelError("","дата начала продажи не может быть больше даты окончания");
                //}
                db.Films.AddOrUpdate(film);

                db.SaveChanges();
                return RedirectToAction("Index");
            }

            TempData["error"] = ModelState;
            return RedirectToAction("AddOrEditFilm");
        }