示例#1
0
        public void Add(IInvoicePosition position)
        {
            position.CheckArgument(nameof(position));

            var pos = new InvoicePosition();

            pos.CopyProperties(position);
            PositionEntities.Add(pos);
        }
示例#2
0
        public void CopyProperties(IInvoice other)
        {
            other.CheckArgument(nameof(other));
            other.InvoiceHead.CheckArgument(nameof(other));
            other.InvoicePositions.CheckArgument(nameof(other));

            HeadEntity.CopyProperties(other.InvoiceHead);
            PositionEntities.Clear();
            foreach (var item in other.InvoicePositions)
            {
                var pos = new InvoicePosition();

                pos.CopyProperties(item);
                PositionEntities.Add(pos);
            }
        }
        public async Task <IInvoice> InsertAsync(IInvoice entity)
        {
            entity.CheckArgument(nameof(entity));
            entity.InvoiceHead.CheckArgument(nameof(entity));
            entity.InvoicePositions.CheckArgument(nameof(entity));

            var invoice = new Invoice();

            invoice.HeadEntity.CopyProperties(entity.InvoiceHead);
            await headController.InsertAsync(invoice.HeadEntity);

            foreach (var item in entity.InvoicePositions)
            {
                var pos = new InvoicePosition();
                pos.CopyProperties(item);
                pos.InvoiceHead = invoice.HeadEntity;

                await positionController.InsertAsync(item);

                invoice.Add(item);
            }

            return(invoice);
        }