コード例 #1
0
        public ActionResult Index(GenreEditModel model)
        {
            if (ModelState.IsValid)
                return RedirectToAction("Index");

            return View(model);
        }
コード例 #2
0
        public ActionResult Create()
        {
            var model = new GenreEditModel
            {
                StartDate = DateTime.Now.AddDays(2),
                DateToCompareAgainst = DateTime.Now
            };

            return View(model);
        }
コード例 #3
0
        public ActionResult Index(GenreEditModel model)
        {
            Thread.Sleep(10000);
            throw new Exception("exception");

            if (ModelState.IsValid)
            {
                return PartialView("Thanks");
            }
            return PartialView("_Create");
        }
コード例 #4
0
        public ActionResult Create(GenreEditModel model)
        {
            if (ModelState.IsValid)
                return RedirectToAction("Index");

            var genre = new Genre { Name = model.Name, Description = model.Description };

            _genreService.Add(genre);

            return View(model);
        }
コード例 #5
0
        public ActionResult Edit(int id = 0)
        {
            var genre = _genreService.GetGenre(id);
            if (genre == null)
                return HttpNotFound();

            var model = new GenreEditModel()
                            {
                                Id = genre.Id,
                                Name = genre.Name,
                                Description = genre.Description
                            };

            return View("Create", model);
        }