Beispiel #1
0
        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));
        }
Beispiel #2
0
        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));
        }
Beispiel #3
0
 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));
 }
Beispiel #4
0
 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));
 }
Beispiel #5
0
 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));
 }