Beispiel #1
0
        public async Task AddSaleFactor(AddSalesFactorDto dto)
        {
            var good = await _goodRepository.GetGoodById(dto.GoodId);

            if (good == null)
            {
                throw new Exception();
            }

            if (good.MinimumStack < dto.GoodCount)
            {
                throw new GoodCountLessThanSaleCount();
            }

            var salesFactor = new SaleFactors
            {
                GoodCount = dto.GoodCount,
                SalesDate = DateTime.Now,
                GoodId    = dto.GoodId
            };

            good.MinimumStack -= dto.GoodCount;

            _repository.AddSaleFactor(salesFactor);


            _unitOfWork.Complete();
        }
 public void AddSaleFactor(SaleFactors salesFactors)
 {
     _dataContext.SaleFactors.AddAsync(salesFactors);
 }