Example #1
0
        public IEnumerable <BillingItem> GetBillingItems(int billNo)
        {
            var billingItems = BillingItems.Where(b => b.BillId == billNo);

            foreach (var r in billingItems)
            {
                r.Item = Items.Single(i => i.ItemId == r.ItemId);
                r.Bill = Bills.Single(b => b.BillId == r.BillId);
            }

            return(billingItems);
        }
Example #2
0
        public void DeleteBill(int billId)
        {
            var billingItems = BillingItems.Where(b => b.BillId == billId).ToList();

            if (!billingItems.Any())
            {
                BillingItems.RemoveRange(billingItems);
            }

            var bill = Bills.Single(b => b.BillId == billId);

            if (bill == null)
            {
                throw new Exception($"Not able find the bill for billId {billId}");
            }

            Bills.Remove(bill);

            SaveChanges();
        }