Exemple #1
0
        public HttpResponseMessage UserReg(tblNetBanking tblbank)
        {
            proc_test1_Result  result  = null;
            proc_test21_Result result2 = null;
            proc_test31_Result result3 = null;

            result  = entities.proc_test1(tblbank.user_id).FirstOrDefault();
            result2 = entities.proc_test21(tblbank.user_id).FirstOrDefault();
            result3 = entities.proc_test31(tblbank.user_id).FirstOrDefault();

            if (result2 != null)
            {
                if (result3 != null)
                {
                    return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Already Registered"));
                }
                else
                {
                    tblBalance bal = new tblBalance();
                    bal.account_number = tblbank.account_number;
                    bal.customer_id    = tblbank.user_id;
                    bal.balance        = 25000;
                    entities.tblNetBankings.Add(tblbank);
                    entities.tblBalances.Add(bal);
                    entities.SaveChanges();
                    return(Request.CreateResponse <proc_test1_Result>(result));
                }
            }
            else
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "User ID not found"));
            }
        }
        public void GetLoanApplicationWithBalance_LoanAmountUnder1000_NullValuesReturned()
        {
            var name            = "sumon";
            var loanApplication = new tblLoanApplication
            {
                Name   = name,
                Amount = 140,
                Id     = 1
            };
            var balance = new tblBalance
            {
                Name    = "sumon",
                Balance = 3500,
                Id      = 3
            };

            _loanApplicationUow.Setup(l => l.Repository <tblLoanApplication>().Get(It.IsAny <Func <tblLoanApplication, bool> >()))
            .Returns(loanApplication);

            _loanApplicationUow.Setup(l => l.Repository <tblBalance>().Get(It.IsAny <Func <tblBalance, bool> >()))
            .Returns(balance);
            var result = _loanApplicationService.GetLoanApplicationWithBalance(name);

            (result.BalanceAmount).Should().Be(null);
            (result.LoanAmount).Should().Be(null);
        }
Exemple #3
0
        public static void AddBalance(string NationalNumber, int Balance)
        {
            using (EGovernmentEntities db = new EGovernmentEntities())
            {
                tblBalance balance = new tblBalance();
                balance.NationalNumber = NationalNumber;
                balance.Balance        = Balance;

                db.tblBalances.AddObject(balance);

                db.SaveChanges();
            }
        }
Exemple #4
0
        public static bool HasBalance(string NationalNumber)
        {
            bool res = false;

            using (EGovernmentEntities db = new EGovernmentEntities())
            {
                tblBalance balance = db.tblBalances.Where(x => x.NationalNumber == NationalNumber).FirstOrDefault();

                res = balance != null;
            }

            return(res);
        }
Exemple #5
0
        public static void Pay(string NationalNumber, int Penalty)
        {
            using (EGovernmentEntities db = new EGovernmentEntities())
            {
                tblBalance balance = db.tblBalances.Where(x => x.NationalNumber == NationalNumber).FirstOrDefault();

                if (balance != null)
                {
                    balance.Balance = balance.Balance - Penalty;
                }

                db.SaveChanges();
            }
        }
Exemple #6
0
        public HttpResponseMessage AddBenificiary(tblBeneficiary beneficiary)
        {
            tblBalance balance = entities.tblBalances.Where(b => b.account_number == beneficiary.account_number).FirstOrDefault();

            if (beneficiary == null)
            {
                entities.tblBeneficiaries.Add(beneficiary);
                entities.SaveChanges();
                return(Request.CreateResponse(HttpStatusCode.Created, beneficiary));
            }
            else
            {
                return(Request.CreateErrorResponse(HttpStatusCode.NotFound, "Benificiary already exists"));
            }
        }
Exemple #7
0
        public static bool CheckBalance(string NationalNumber, int Penalty)
        {
            bool res = false;

            if (string.IsNullOrEmpty(NationalNumber))
            {
                return(true);
            }

            using (EGovernmentEntities db = new EGovernmentEntities())
            {
                tblBalance balance = db.tblBalances.Where(x => x.NationalNumber == NationalNumber).FirstOrDefault();

                if (balance != null)
                {
                    res = balance.Balance > Penalty; // الميزانية أكبر من الغرامة
                }
            }

            return(res);
        }