Example #1
0
        public static Invoice MapFromEntity(data.Entities.Invoice entity)
        {
            if (entity == null)
                return null;

            var invoice = new Invoice()
            {
                InvoiceId = entity.InvoiceId,
                InvoiceNumber = entity.InvoiceNumber,
                Vendor = Vendor.MapFromEntity(entity.Vendor),
                InvoiceType = InvoiceType.MapFromEntity(entity.InvoiceType),
                InvoiceDate = entity.InvoiceDate,
                DatePaid = entity.DatePaid,
                Description = entity.Description

            };
            
            invoice.AccountTotals = new List<InvoiceAccountTotal>();
            if(entity.InvoiceAccounts != null)
            {
                foreach (var invoiceAccount in entity.InvoiceAccounts)
                {
                    invoice.AccountTotals.Add(InvoiceAccountTotal.MapFromEntity(invoiceAccount));
                }
            }

            //Tickets added from outside if the invoice entity due to the cpmplexit of the ticket entity

            return invoice;
        }
Example #2
0
        public data.Entities.Invoice MapToEntity()
        {
            var entity = new data.Entities.Invoice()
            {
                InvoiceId = this.InvoiceId,
                InvoiceNumber = this.InvoiceNumber,
                VendorId = this.Vendor.VendorId,
                InvoiceTypeId = this.InvoiceType.InvoiceTypeId,
                InvoiceDate = this.InvoiceDate,
                DatePaid = this.DatePaid,
                Description = this.Description,
            };

            entity.InvoiceAccounts = new List<data.Entities.InvoiceAccount>();
            foreach(var account in AccountTotals)
            {
                entity.InvoiceAccounts.Add(account.MapToEntity(this.InvoiceId));
            }

            return entity;
        }