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));
        }
示例#3
0
        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>());
        }
示例#4
0
        public async Task <ApiResult <bool> > Update(UpdateMaterialsType bundle)
        {
            var data = await _materialsTypeApiClient.Update(bundle.Id, bundle);

            return(data);
        }