Exemple #1
0
        public IHttpActionResult Post(DepositModel deposit)
        {
            //while (true)
            //{
            //	Card card = new Card();
            //	card.CardTypeId = 7;
            //	card.CardCompanyId = 9;
            //	card.CardHolderName = "shail";
            //	card.CardNumber = Encrypt("1212121212121212", true);
            //	card.Cvv = 200;
            //	card.ExpiryMonth = 12;
            //	card.ExpiryYear = 24;
            //	card.AccountId = 10;
            //}

            if ((deposit.DepositTypeId == 6) || (deposit.DepositTypeId == 7))
            {
                Card cartObj = new Card();
                var  encrypt = Encrypt((deposit.CardNumber).ToString(), true);
                var  card    = Uow.Repository <Card>().FirstOrDefault(c => (c.CardNumber == encrypt) && (c.Cvv == deposit.CVV));
                var  balance = BalanceDomain.GetBy(19);
                if (card != null)
                {
                    if (card.Amount >= deposit.DepositAmount)
                    {
                        Deposit depositObj = new Deposit();
                        depositObj.UserId        = 19;
                        depositObj.DepositStatus = true;
                        if (deposit.DepositTypeId == 6)
                        {
                            depositObj.DepositTypeId = 3;
                        }
                        else
                        {
                            depositObj.DepositTypeId = 4;
                        }
                        var date = DateTime.Now;
                        depositObj.DepositDate   = date;
                        depositObj.AccountId     = card.AccountId;
                        depositObj.BalanceId     = balance.BalanceId;
                        depositObj.DepositAmount = deposit.DepositAmount;
                        var depositMessage = DepositDomain.Post(depositObj);

                        if (depositMessage == "Deposit Successful!")
                        {
                            balance.BalanceAmount = balance.BalanceAmount + deposit.DepositAmount;
                            card.Amount           = card.Amount - deposit.DepositAmount;
                            BalanceDomain.Put(balance);
                            CardDomain.Put(card);
                            return(Ok("successfull"));
                        }
                        else
                        {
                            return(Ok("error"));
                        }
                    }
                    else
                    {
                        return(Ok("error"));
                    }
                }
                else
                {
                    return(Ok("error"));
                }
            }
            else if (deposit.DepositTypeId == 5)
            {
                var branch  = Uow.Repository <BankBranch>().FirstOrDefault(b => b.IFSC_Code == deposit.IFSC);
                var account = Uow.Repository <AccountDetail>().FirstOrDefault(a => (a.AccountNumber == deposit.AccountNumber) && (a.BankBranchId == branch.BankBranchId));
                if (account != null)
                {
                    if (account.AccountBalance >= deposit.DepositAmount)
                    {
                        Deposit depositObj = new Deposit();
                        var     date       = DateTime.Now;
                        depositObj.DepositDate   = date;
                        depositObj.UserId        = deposit.UserId;
                        depositObj.DepositStatus = true;
                        depositObj.DepositTypeId = deposit.DepositTypeId;
                        depositObj.AccountId     = account.AccountId;
                        var balance = BalanceDomain.GetBy(deposit.UserId);
                        depositObj.BalanceId     = balance.BalanceId;
                        depositObj.DepositAmount = deposit.DepositAmount;
                        var depositMessage = DepositDomain.Post(depositObj);

                        if (depositMessage == "Deposit Successful!")
                        {
                            account.AccountBalance = account.AccountBalance - deposit.DepositAmount;
                            AccountDetailsDomain.Put(account);
                            balance.BalanceAmount = balance.BalanceAmount + deposit.DepositAmount;
                            BalanceDomain.Put(balance);
                            return(Ok("successfull"));
                        }
                        else
                        {
                            return(Ok("error"));
                        }
                    }
                    else
                    {
                        return(Ok("error"));
                    }
                }
                else
                {
                    return(Ok("error"));
                }
            }
            else
            {
                return(Ok("error"));
            }
        }
Exemple #2
0
 public IHttpActionResult Get()
 {
     return(Ok(DepositDomain.Get()));
 }