Example #1
0
        public async Task BuyItem(int amount, int id)
        {
            var entityToBuy = _repository.GetById(id);
            var dtoProductToBuyWithDiscount = _priceCalculationService.ApplyDiscount(entityToBuy, amount);
            var entityForHistory            = _mapper.Map <BoughtProduct>(dtoProductToBuyWithDiscount);

            entityForHistory.Id = null;
            await _repository.AddToSalesHistory(entityForHistory);

            await _repository.RemoveProducts(entityToBuy, amount);
        }