public ActionResult CardBalance(CardModel cardModel) { int ReqAmount = 0; float AvaBalnce = 0; cardModel.Balance = Session["Balance"].ToString(); var cardType = _card.GetCardType(); foreach (var item in cardType.Where(kvp => kvp.Value.ToUpper() == "VIRTUAL CARD" || kvp.Value.ToUpper() == "GIFT CARD").ToList()) { cardType.Remove(item.Key); } cardModel.CardTypeList = ApplicationUtilities.SetDDLValue(cardType as Dictionary <string, string>, "", "--Card Type--"); if (string.IsNullOrEmpty(cardModel.CardNo)) { ModelState.AddModelError("CardNo", "Card Number Required!"); //return RedirectToAction("CardBalance"); return(View("CardBalance", cardModel)); } if (int.TryParse(cardModel.Amount, out ReqAmount) && float.TryParse(cardModel.Balance, out AvaBalnce)) { if (ReqAmount > AvaBalnce && cardModel.Type.ToLower() == "ad") { ModelState.AddModelError("Amount", "Requested amount greater then balance"); return(View("CardBalance", cardModel)); } string userid = Session["UserId"].ToString(); if (string.IsNullOrEmpty(userid)) { return(RedirectToAction("Index", "Home")); } var cardCommonList = _card.GetCardList(userid).Where(x => x.CardId == cardModel.CardNo);//MapObjects<CardModel>(); float AvailableCardBalance = 0; if (float.TryParse(cardCommonList.FirstOrDefault().Amount, out AvailableCardBalance)) { if (ReqAmount > AvailableCardBalance && cardModel.Type.ToLower() == "rb") { ModelState.AddModelError("Amount", "Requested amount greater then balance"); return(View("CardBalance", cardModel)); } } } CardCommon cardCommon = cardModel.MapObject <CardCommon>(); //CommonDbResponse dbResponse = _card.CardApproval(cardCommon); CommonDbResponse dbResponse = _card.CardBalance(cardCommon); dbResponse.SetMessageInTempData(this, "Index"); return(RedirectToAction("Index")); }