コード例 #1
0
        public async Task <IActionResult> Update(int id, [FromBody] UpdateMaterialResource resource)
        {
            var material = _mapper.Map <UpdateMaterialResource, Material>(resource);

            material.Id = id;
            var result = await _materials.UpdateAsync(material);

            if (!result.Success)
            {
                return(BadRequest(new ErrorResource(result.Messages)));
            }

            var materialResource = _mapper.Map <Material, MaterialResource>(result.Resource);

            return(Ok(materialResource));
        }