Пример #1
0
        public override void Insert(InvoiceServiceModel serviceModel, int currentUserId)
        {
            var invoice = new Invoice
            {
                Date   = serviceModel.Date,
                Number = serviceModel.Number,
            };
            var id = _invoiceRepository.InsertAndGetId(invoice, currentUserId);

            foreach (var item in serviceModel.InvoiceDetails)
            {
                var invoiceDetail = new InvoiceDetail()
                {
                    InvoiceId = id,
                    Count     = item.Count,
                    Price     = item.Price,
                    ProductId = item.ProductId
                };
                _invoiceDetailRepository.Insert(invoiceDetail, currentUserId);
            }
        }