예제 #1
0
        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));
        }
예제 #3
0
 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));
     }
 }
예제 #4
0
 public IHttpActionResult Post(House house)
 {
     return(Ok(_houseService.Add(house)));
 }
예제 #5
0
 public void Post([FromBody] HouseDTO value)
 {
     _service.Add(_mapper.Map <House>(value));
 }