public void Update(int id, [FromBody] UpdateGoodDto dto) { Good theGood = _context.Goods.Find(id); theGood.Title = dto.Title; theGood.Code = dto.Code; _context.Update(theGood); _context.SaveChanges(); }
public ActionResult <Result <GetGoodDto> > Put([FromBody] UpdateGoodDto goodDto) { var resultFromRepository = goodsRepository.Update(goodConverter.FromUpdateDto(goodDto)); return(new Result <GetGoodDto> { IsSuccess = resultFromRepository.IsSuccess, Message = resultFromRepository.Message, Value = resultFromRepository.Value != null ? goodConverter.ToGetDto(resultFromRepository.Value) : null }); }
public Good FromUpdateDto(UpdateGoodDto updateGoodDto) { return(new Good { Id = updateGoodDto.Id, QuantityType = updateGoodDto.QuantityType, UnitPrice = updateGoodDto.UnitPrice, Description = updateGoodDto.Description, Components = updateGoodDto.Components.Select(c => new GoodComponent { Id = c.Id, Quantity = c.Quantity }).ToList() }); }
public async Task EditGoodInfo(UpdateGoodDto dto, int id) { var good = await GetGoodById(id); if (good == null) { throw new GoodNotFoundById(); } good.Title = dto.Title; good.WareHouseId = dto.WareHouseId; good.MinimumStack = dto.MinimumStack; good.Price = dto.Price; good.CategoryId = dto.CategoryId; _unitOfWork.Complete(); }
public async Task Edit(UpdateGoodDto dto, int id) { await _service.EditGoodInfo(dto, id); }