public HttpResponseMessage Post([FromBody] CreatePublisherViewModel model) { if (!ModelState.IsValid) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState)); } var publisherDto = Mapper.Map <PublisherDTO>(model); _publisherService.AddEntity(publisherDto); return(Request.CreateResponse(HttpStatusCode.Created)); }
public HttpResponseMessage Post([FromBody] CreateGenreViewModel model) { if (!ModelState.IsValid) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState)); } var genreDto = Mapper.Map <GenreDTO>(model); _genreService.AddEntity(genreDto); return(Request.CreateResponse(HttpStatusCode.Created)); }
public ActionResult New(CreatePlatformTypeViewModel createType) { if (ModelState.IsValid) { var typeDto = Mapper.Map <PlatformTypeDTO>(createType); _typeService.AddEntity(typeDto); return(RedirectToAction("Index")); } createType.Translates = new List <TranslateViewModel> { new TranslateViewModel { Id = Guid.NewGuid().ToString(), Language = Language.ru } }; return(View("New", createType)); }
public ActionResult New(CreatePublisherViewModel createPublisher) { if (ModelState.IsValid) { var publisherDto = Mapper.Map <PublisherDTO>(createPublisher); _publisherService.AddEntity(publisherDto); return(RedirectToAction("Index")); } createPublisher.Translates = new List <TranslateViewModelDescription> { new TranslateViewModelDescription { Id = Guid.NewGuid().ToString(), Language = Language.ru } }; return(View("New", createPublisher)); }
public ActionResult New(CreateGenreViewModel createGenre) { if (ModelState.IsValid) { var genreDto = Mapper.Map <GenreDTO>(createGenre); _genreService.AddEntity(genreDto); return(RedirectToAction("Index")); } createGenre.Translates = new List <TranslateViewModel> { new TranslateViewModel { Id = Guid.NewGuid().ToString(), Language = Language.ru } }; createGenre.AllGenres = Mapper.Map <IEnumerable <GenreViewModel> >(_genreService.GetAll(false)); return(View("New", createGenre)); }