Ejemplo n.º 1
0
        public ActionResult AgentRT(BalanceModel balanceModel)
        {
            //BalanceModel balanceModel = new BalanceModel();
            List <BalanceCommon>        balanceCommons = _balance.GetAgentName();
            Dictionary <string, string> agentName      = new Dictionary <string, string>();
            Dictionary <string, string> bankList       = _balance.GetBankList();

            foreach (BalanceCommon bcommon in balanceCommons)
            {
                agentName.Add(bcommon.AgentId, bcommon.Name);
            }
            balanceModel.NameList        = ApplicationUtilities.SetDDLValue(agentName, "", "--Agent--");
            balanceModel.BankAccountList = ApplicationUtilities.SetDDLValue(bankList, "", "--Bank--");

            if (Convert.ToDecimal(balanceModel.Amount) > 500000 && balanceModel.Type == "T")
            {
                ModelState.AddModelError("Amount", "Amount Cannot Be Greater then 500000 (5 Lakhs)");
                return(View(balanceModel));
            }

            if (balanceModel.Type == "R")
            {
                ModelState.Remove(("BankId"));
                if (Convert.ToDecimal(balanceModel.Amount) > 100000 && balanceModel.Type == "R")
                {
                    ModelState.AddModelError("Amount", "Amount Cannot Be Greater then 100000 (1 Lakh)");
                    return(View(balanceModel));
                }
            }

            if (ModelState.IsValid)
            {
                balanceModel.CreatedBy = Session["UserName"].ToString();
                balanceModel.AgentId   = agentName.FirstOrDefault(x => x.Key == balanceModel.Name).Key.ToString();
                balanceModel.Name      = agentName.FirstOrDefault(x => x.Key == balanceModel.Name).Value.ToString();
                if (balanceModel.Type == "T")
                {
                    balanceModel.BankName = bankList.FirstOrDefault(x => x.Key == balanceModel.BankId).Value.ToString();
                }
                balanceModel.CreatedIp = ApplicationUtilities.GetIP();

                BalanceCommon    balanceCommon = balanceModel.MapObject <BalanceCommon>();
                CommonDbResponse dbResponse    = _balance.AgentTR(balanceCommon);
                if (dbResponse.Code == 0)
                {
                    dbResponse.SetMessageInTempData(this);
                    return(RedirectToAction("AgentRT", ControllerName));
                }
            }
            else
            {
                return(View(balanceModel));
            }

            return(RedirectToAction("AgentRT", ControllerName));
        }