예제 #1
0
        public List <InvoiceDisplayDto> GetAllInvoices()
        {
            var invoiceBookings = _dbInvoiceBooking.GetAll();

            var result = new List <InvoiceDisplayDto>();

            foreach (var item in invoiceBookings)
            {
                var booking        = _dbBooking.GetAll().First(x => x.Id == item.BookingId);
                var invoice        = _dbInvoice.GetAll().First(x => x.Id == item.InvoiceId);
                var invoiceDisplay = new InvoiceDisplayDto()
                {
                    BookingId         = item.BookingId,
                    InvoiceId         = item.InvoiceId,
                    InvoiceDate       = item.InvoiceDate,
                    IsPaid            = item.IsPaid,
                    IsSent            = item.IsSent,
                    PayedUpDate       = item.PayedUpDate,
                    OutStandingAmount = item.OutStandingAmount,
                    BookingNumber     = booking.BookingNumber,
                    InvoiceNumber     = invoice.InvoiceNumber,
                    TotalAmount       = invoice.TotalAmount,
                    InvoiceItems      = new List <InvoiceItem>()
                };
                invoiceDisplay.InvoiceItems = _dbInvoiceItem.GetAll().Where(x => x.InvoiceId == item.InvoiceId).ToList();
                result.Add(invoiceDisplay);
            }


            return(result);
        }
예제 #2
0
        public InvoiceDisplayDto GetInvoice(int id)
        {
            var item           = _dbInvoiceBooking.GetAll().First(x => x.Id == id);
            var booking        = _dbBooking.GetAll().First(x => x.Id == item.BookingId);
            var invoice        = _dbInvoice.GetAll().First(x => x.Id == item.InvoiceId);
            var invoiceDisplay = new InvoiceDisplayDto()
            {
                BookingId         = item.BookingId,
                InvoiceId         = item.InvoiceId,
                InvoiceDate       = item.InvoiceDate,
                IsPaid            = item.IsPaid,
                IsSent            = item.IsSent,
                PayedUpDate       = item.PayedUpDate,
                OutStandingAmount = item.OutStandingAmount,
                BookingNumber     = booking.BookingNumber,
                InvoiceNumber     = invoice.InvoiceNumber,
                TotalAmount       = invoice.TotalAmount,
                InvoiceItems      = new List <InvoiceItem>()
            };

            invoiceDisplay.InvoiceItems = _dbInvoiceItem.GetAll().Where(x => x.InvoiceId == item.InvoiceId).ToList();
            return(invoiceDisplay);
        }