Esempio n. 1
0
        public IActionResult Add(Apartment apartment)
        {
            var result = _customerService.Add(apartment);

            if (result.Success)
            {
                return(Ok(result));
            }
            return(BadRequest(result));
        }
Esempio n. 2
0
 public HttpResponseMessage Create(HttpRequestMessage request, ApartmentViewModel apartmentViewModel)
 {
     return(CreateHttpResponse(request, () =>
     {
         HttpResponseMessage response = null;
         if (!ModelState.IsValid)
         {
             response = request.CreateResponse(HttpStatusCode.BadRequest, ModelState);
         }
         else
         {
             var newApartment = new Apartment();
             newApartment.UpdateApartment(apartmentViewModel);
             newApartment.CreatedDate = DateTime.Now;
             newApartment.CreatedBy = "Administrator";
             _apartmentService.Add(newApartment);
             _apartmentService.SaveChanges();
             var responseData = Mapper.Map <Apartment, ApartmentViewModel>(newApartment);
             response = request.CreateResponse(HttpStatusCode.Created, responseData);
         }
         return response;
     }));
 }