Esempio n. 1
0
        public async Task <IActionResult> CreateProperty([FromBody] SaveEditPropertyResource resource)
        {
            if (await _propertyService.CheckIfPropertyTitleExists(resource.Title))
            {
                return(BadRequest(_response.Error("Property with same title already exists")));
            }

            var property = _mapper.Map <Property>(resource);

            property = await _propertyService.CreateProperty(property, User.GetUserId());

            var propertyResource = _mapper.Map <PropertyResource>(property);

            return(Ok(_response.Ok(propertyResource)));
        }