public async Task <ApiResult <bool> > Update(int id, UpdateMaterialsType bundle) { var json = JsonConvert.SerializeObject(bundle); var httpContent = new StringContent(json, Encoding.UTF8, "application/json"); var url = $"/api/MaterialsType/" + $"{id}"; var result = await Update(url, httpContent); return(result); }
public async Task <IActionResult> Update(int id, [FromBody] UpdateMaterialsType request) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var result = await _materialsTypeService.Update(id, request); if (!result.IsSuccessed) { return(BadRequest(result)); } return(Ok(result)); }
public async Task <ApiResult <bool> > Update(int id, UpdateMaterialsType bundle) { var materialsType = await _context.MaterialsTypes.FindAsync(bundle.Id); if (materialsType == null) { return(new ApiErrorResult <bool>("Loại nguyên vật liệu không tồn tại")); } var list = _mapper.Map(bundle, materialsType); _context.MaterialsTypes.Update(list); await _context.SaveChangesAsync(); return(new ApiSuccessResult <bool>()); }
public async Task <ApiResult <bool> > Update(UpdateMaterialsType bundle) { var data = await _materialsTypeApiClient.Update(bundle.Id, bundle); return(data); }