public async Task <IActionResult> Update([FromRoute] Guid id, [FromBody] MaterialOnHouseTypeRequest request) { var materialOnHouseType = await _repositoryService.GetByIdAsync(id); materialOnHouseType.FmHouseTypeId = request.FmHouseTypeId; materialOnHouseType.MaterialId = request.MaterialId; materialOnHouseType.MaterialAmount = request.MaterialAmount; var updated = await _repositoryService.UpdateAsync(materialOnHouseType); if (updated) { return(Ok(MaterialOnHouseTypeToMaterialOnHouseTypeResponse(materialOnHouseType))); } return(NotFound()); }
public async Task <IActionResult> Create([FromBody] MaterialOnHouseTypeRequest materialOnHouseTypeRequest) { var materialOnHouseType = new MaterialOnHouseType { MaterialId = materialOnHouseTypeRequest.MaterialId, FmHouseTypeId = materialOnHouseTypeRequest.FmHouseTypeId, MaterialAmount = materialOnHouseTypeRequest.MaterialAmount }; await _repositoryService.CreateAsync(materialOnHouseType); var baseurl = $"{HttpContext.Request.Scheme}://{HttpContext.Request.Host.ToUriComponent()}"; var locationuri = baseurl + "/" + ApiRoutes.MaterialOnHouseTypes.Get.Replace("{materialOnHouseTypeId}", materialOnHouseType.Id.ToString()); var response = MaterialOnHouseTypeToMaterialOnHouseTypeResponse(materialOnHouseType); return(Created(locationuri, response)); }