Пример #1
0
        public async Task AddQuotationItemAsync(Guid quotationId, Guid itemId, Guid priceListId, Guid?taxId, int units = 1)
        {
            Guard.AgainstNull(quotationId, nameof(quotationId));
            Guard.AgainstNull(priceListId, nameof(priceListId));
            Guard.AgainstNull(itemId, nameof(itemId));

            Quotation quotation = await _quotationRepository.GetByIdAsync(quotationId);

            Item item = await _itemRepository.GetByIdAsync(itemId);

            ItemQuoted itemQuoted = new(item.Id, item.Name, item.Description);

            PriceList priceList = await _priceListRepository.GetByIdAsync(priceListId);

            QuotationItem quotationItem = new(itemQuoted, priceList.UnitPrice, units, taxId);

            quotation.AddItem(quotationItem);

            await _quotationRepository.UpdateAsync(quotation);
        }