[HttpPost, Route("update")] //, AmigoTenantClaimsAuthorize(ActionCode = ConstantsSecurity.ActionCode.HouseUpdate)] public async Task <ResponseDTO> Update(UpdateHouseRequest house) { if (ModelState.IsValid) { return(await _houseApplicationService.UpdateHouseAsync(house)); } return(ModelState.ToResponse()); }
public async Task <ResponseDTO> UpdateHouseAsync(UpdateHouseRequest house) { //Map to Command var command = _mapper.Map <UpdateHouseRequest, UpdateHouseCommand>(house); //Execute Command var resp = await _bus.SendAsync(command); return(ResponseBuilder.Correct(resp, command.HouseId, command.Code)); //return ResponseBuilder.Correct(resp); }
public async Task <IActionResult> UpdateHouse([FromBody] UpdateHouseRequest request) { if (request is null) { return(BadRequest(new FailedHouseResponse { Errors = new [] { "Request should have a valid data." }, Status = false })); } //Checking all props have values if (PropertyHelper.IsAnyPropIsNull(request)) { return(BadRequest( new FailedHouseResponse { Status = false, Errors = new[] { "House properties can not be null." } } )); } var updateHouseResponse = await _houseService.UpdateHouseAsync(request.UpdateHouseRequestToUpdateHouseDto()); if (!updateHouseResponse.Status) { if (updateHouseResponse.ServerError) { return(StatusCode(500)); } if (updateHouseResponse.Errors.Contains("Item not found")) { return(NotFound("Item not found")); } return(BadRequest(new FailedHouseResponse { Errors = updateHouseResponse.Errors, Status = updateHouseResponse.Status })); } return(Ok(new SuccessUpdateHouseResponse { House = updateHouseResponse.UpdateHouseDtoToHouseDto(), Status = updateHouseResponse.Status })); }
private static UpdateHouseDto ConvertUpdateHouseRequestToUpdateHouseDto(UpdateHouseRequest request) { return(new UpdateHouseDto { House = new HouseDto { Id = request.Id, HouseNumber = request.HouseNumber, StreetName = request.StreetName, City = request.City, Country = request.Country, PostCode = request.PostCode } }); }
public static UpdateHouseDto UpdateHouseRequestToUpdateHouseDto(this UpdateHouseRequest request) => ConvertUpdateHouseRequestToUpdateHouseDto(request);