Exemplo n.º 1
0
 public IHttpActionResult PostWish(CityViewModel city)
 {
     if (!ModelState.IsValid)
     {
         return(BadRequest(ModelState));
     }
     try
     {
         string currentUser = RequestContext.Principal.Identity.Name;
         Mapper.Initialize(cfg => cfg.CreateMap <CityViewModel, CityDTO>());
         var cityDTO = Mapper.Map <CityViewModel, CityDTO>(city);
         travelService.AddCityToWish(cityDTO, currentUser);
         return(Ok());
     }
     catch (ValidationException ex)
     {
         return(Content(HttpStatusCode.BadRequest, ex.Message));
     }
 }