Esempio n. 1
0
        public ActionResult RequestCard(CardModel cardModels)
        {
            int   ReqAmount = 0;
            float AvaBalnce = 0;

            cardModels.Balance = Session["Balance"].ToString();
            //CardModel cardModel = new CardModel();
            var cardType = _card.GetCardType();

            foreach (var item in cardType.Where(kvp => kvp.Value.ToUpper() == "VIRTUAL CARD").ToList())
            {
                cardType.Remove(item.Key);
            }
            cardModels.CardTypeList = ApplicationUtilities.SetDDLValue(cardType as Dictionary <string, string>, "", "--Card Type--");

            if (int.TryParse(cardModels.Amount, out ReqAmount))
            {
                if (ReqAmount < 100) //|| ReqAmount>1000
                {
                    ModelState.AddModelError("Amount", "Amount should be at least RS. 100");
                    return(View(cardModels));
                }
            }
            else
            {
                ModelState.AddModelError("Amount", "Invalid Requested amount.");
                return(View(cardModels));
            }
            if (float.TryParse(cardModels.Balance, out AvaBalnce))
            {
                if (ReqAmount > AvaBalnce)
                {
                    ModelState.AddModelError("Amount", "Requested amount greater then balance");
                    return(View(cardModels));
                }
            }
            cardModels.UserId   = Session["UserId"].ToString();
            cardModels.AgentId  = Session["AgentId"].ToString();
            cardModels.UserName = Session["UserName"].ToString();
            //cardModels.UserName = Session["FullName"].ToString();
            WalletUserInfo walletUser = _walletUserBusiness.UserInfo(cardModels.UserId);

            cardModels.Email      = walletUser.Email;
            cardModels.MobileNo   = walletUser.MobileNo;
            cardModels.ActionUser = cardModels.UserName;
            cardModels.CreatedIp  = ApplicationUtilities.GetIP();
            CardCommon cardCommon = cardModels.MapObject <CardCommon>();
            //CommonDbResponse dbResponse = _card.CardApproval(cardCommon);
            CommonDbResponse dbResponse = _card.RequestCard(cardCommon);

            if (dbResponse.Code == 0)
            {
                //dbResponse.SetMessageInTempData(this, "Index");
                return(RedirectToAction("Index"));
            }
            dbResponse.SetMessageInTempData(this, "Index");
            return(View(cardModels));
        }