Beispiel #1
0
        public async Task <IActionResult> PostAsync(int partnerId, int locatableId, [FromBody] SaveEstateResource resource)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState.GetErrorMessages()));
            }
            var estate = _mapper.Map <SaveEstateResource, Estate>(resource);

            estate.LocatableId = locatableId;
            estate.PartnerId   = partnerId;

            var result = await _estateService.SaveAsync(estate);

            if (!result.Success)
            {
                return(BadRequest(result.Message));
            }

            var estateResource = _mapper.Map <Estate, EstateResource>(result.Resource);

            return(Ok(estateResource));
        }