Ejemplo n.º 1
0
        public async Task <IActionResult> UpdateAsync(string id, [FromBody] ResourceRequest <BuildingRequestDto> resource)
        {
            if (resource.Data.Type != "buildings" || resource.Data.Id != id)
            {
                return(StatusCode(409));
            }

            var building = _mapper.Map <Building>(resource.Data);

            building = await _buildingManager.UpdateAsync(building);

            var buildingDto = _mapper.Map <BuildingDto>(building);
            var links       = _jsonApiBuilder.BuildSingleResourceLinks(HttpContext.Request.Path);

            return(Ok(new ResourceResponse()
            {
                Links = links, Data = buildingDto
            }));
        }