Exemplo n.º 1
0
        public BillInformation GetBillInfo(int id)
        {
            var billInfo = new BillInformation();
            var bill     = context.GroupBills.SingleOrDefault(b => b.Gb_Id == id);
            var bm       = context.Users.SingleOrDefault(m => m.U_Id == bill.Gb_PaidBy);
            var grp      = context.Groups.SingleOrDefault(i => i.G_Id == bill.Gb_ForGroup);

            billInfo.BI_Id      = bill.Gb_Id;
            billInfo.BI_Name    = bill.Gb_Name;
            billInfo.BI_PaidBy  = bm.U_Name;
            billInfo.BI_PaidFor = new List <string>(new string[] { grp.G_Name });
            billInfo.BI_Date    = bill.Gb_DateTime;
            billInfo.BI_Amount  = bill.Gb_Amount;
            return(billInfo);
        }
Exemplo n.º 2
0
        public BillInformation GetIndividualBillInfo(int id)
        {
            var flist    = new List <string>(new string[] { });
            var billInfo = new BillInformation();
            var bill     = context.IndividualBills.SingleOrDefault(b => b.Ib_Id == id && b.Ib_Deleted == false);
            var us       = context.Users.SingleOrDefault(m => m.U_Id == bill.Ib_PaidBy);
            var mem      = context.BillMembers.Where(i => i.Bm_BillId == id).ToList();

            billInfo.BI_Id     = bill.Ib_Id;
            billInfo.BI_Name   = bill.Ib_Name;
            billInfo.BI_PaidBy = us.U_Name;
            for (int i = 0; i < mem.Count; i++)
            {
                var temp = context.Users.SingleOrDefault(u => u.U_Id == mem[i].Bm_Paidfor);
                flist.Add(temp.U_Name);
            }
            billInfo.BI_PaidFor = flist;
            billInfo.BI_Amount  = bill.Ib_Amount;
            return(billInfo);
        }
Exemplo n.º 3
0
        public BillInformation GetBillInformation(string billId, string paymentId)
        {
            BillInformation information = new BillInformation();

            if (string.IsNullOrEmpty(billId))
            {
                throw new NullReferenceException($"{nameof(billId)} is null or empty");
            }
            if (billId.Length < 6)
            {
                throw new InvalidLenghtException($"{nameof(billId)} lenght is less than 6");
            }
            if (billId.Length > 13)
            {
                throw new InvalidLenghtException($"{nameof(billId)} lenght is more than 13");
            }

            if (string.IsNullOrEmpty(paymentId))
            {
                throw new NullReferenceException($"{nameof(paymentId)} is null or empty");
            }
            if (paymentId.Length < 6)
            {
                throw new InvalidLenghtException($"{nameof(paymentId)} lenght is less than 6");
            }
            if (paymentId.Length > 13)
            {
                throw new InvalidLenghtException($"{nameof(paymentId)} lenght is more than 13");
            }

            information.Type         = ExtractBillType(billId);
            information.PaymentPerid = ExtractPaymentPerid(paymentId);
            information.Year         = ExtractYear(paymentId);
            information.Amount       = ExtractAmount(paymentId);
            information.BillId       = billId;
            information.PaymentId    = paymentId;

            return(information);
        }