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();
        }
Exemplo n.º 2
0
        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
            });
        }
Exemplo n.º 3
0
 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()
     });
 }
Exemplo n.º 4
0
        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();
        }
Exemplo n.º 5
0
 public async Task Edit(UpdateGoodDto dto, int id)
 {
     await _service.EditGoodInfo(dto, id);
 }