コード例 #1
0
        public ActionResult Create(CreateGenreViewModel model)
        {
            if (!ModelState.IsValid) { return View(model); }

            var request = new CreateGenreRequest { Name = model.Name, Description = model.Description };

            _genreService.CreateGenre(request);

            return RedirectToAction("Index");
        }
コード例 #2
0
        public CreateGenreResponse CreateGenre(CreateGenreRequest request)
        {
            var response = new CreateGenreResponse();

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

            ThrowExceptionIfGenreIsInvalid(genre);

            _genreRepository.Add(genre);

            _uow.Commit();

            MvcSiteMapProvider.SiteMaps.ReleaseSiteMap();

            response.Genre = genre.ConvertToGenreView();

            return response;
        }