public HttpResponseMessage Post([FromBody] HouseDto houseDto) { if (!ModelState.IsValid) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Missing values")); } string result = _houseService.Add(houseDto); return(Request.CreateResponse(HttpStatusCode.OK, result)); }
public IActionResult Add(House house) { var result = _houseService.Add(house); if (result.Success) { return(Ok(result)); } return(BadRequest(result)); }
public IActionResult Post([FromBody] HouseModel houseModel) { try { var house = houseModel.ToDomainModel(); _houseService.Add(house); var newHouseModel = house.ToApiModel(); return(Ok(newHouseModel)); } catch (System.Exception ex) { ModelState.AddModelError("AddHouse", ex.Message); return(BadRequest(ModelState)); } }
public IHttpActionResult Post(House house) { return(Ok(_houseService.Add(house))); }
public void Post([FromBody] HouseDTO value) { _service.Add(_mapper.Map <House>(value)); }