public CurrentAmountDetailsModel CurrentAmountDetails(string UserId)
        {
            var data = entities.Users.Where(x => x.UserID == UserId).FirstOrDefault();
            GeneralFunctions generalFunctions = new GeneralFunctions();
            var earning = generalFunctions.getEarningHeads();

            return(new CurrentAmountDetailsModel()
            {
                AccountNumber = data.AccountNumber != null ? data.AccountNumber : "",
                NameInAccount = data.NameInAccount != null ? data.NameInAccount : "",
                IFSCCode = data.IFSCCode != null ? data.IFSCCode : "",
                Bank = data.Bank != null ? data.Bank : "",
                amount = data.CurrentBalance != null?Convert.ToDouble(generalFunctions.GetDecimalvalue(data.CurrentBalance.ToString())) : 0,
                             chargesAmount = earning.WithdrawCharges
            });
        }
        public RedeemBalanceModel PointRedeem(PointsRedeemModel model)
        {
            string passcode = entities.Users.Where(x => x.Passcode == model.Passcode).Select(x => x.Passcode).FirstOrDefault();

            if (passcode != null)
            {
                var data  = entities.Users.Where(x => x.UserID == model.UserID).FirstOrDefault();
                var data1 = entities.AspNetUsers.Where(x => x.Id == model.UserID).FirstOrDefault();
                GeneralFunctions general = new GeneralFunctions();
                if (data.CurrentPoint >= model.PointsWithdraw && general.PointReddemValueCheck(model.PointsWithdraw))
                {
                    EaningHeadModel earningHeads = new EaningHeadModel();
                    var             jsonFilePath = HttpContext.Current.Server.MapPath("~/Models/JsonFile/LevelEarningMasterUser.json");
                    using (StreamReader r = new StreamReader(jsonFilePath))
                    {
                        string json = r.ReadToEnd();
                        earningHeads = JsonConvert.DeserializeObject <EaningHeadModel>(json);
                    }
                    //Insert User Point Table
                    UserPoint Point = new UserPoint()
                    {
                        UserID          = model.UserID,
                        TransactionDate = DateTime.UtcNow.AddHours(5.00).AddMinutes(30.00),
                        PointsWithdraw  = model.PointsWithdraw,
                        PointsEarned    = 0,
                        Description     = "Point Withdrawal in Account",
                        CreatedDate     = DateTime.UtcNow.AddHours(5.00).AddMinutes(30.00)
                    };
                    entities.UserPoints.Add(Point);
                    entities.SaveChanges();

                    //Insert Transaction Table
                    double           balance          = model.PointsWithdraw * earningHeads.PointAmount;
                    GeneralFunctions generalFunctions = new GeneralFunctions();
                    balance = Convert.ToDouble(generalFunctions.GetDecimalvalue(balance.ToString()));
                    var         uniqueKey   = $"{data.UserID}~{DateTime.UtcNow.AddHours(5.00).AddMinutes(30.00).ToString("dd-MM-yyy")}~Earning";
                    Transaction transaction = new Transaction()
                    {
                        UserID = model.UserID,
                        transactionDateTime = DateTime.UtcNow.AddHours(5.00).AddMinutes(30.00),
                        UniqueKey           = uniqueKey,
                        paymentStatus       = "points",
                        amount          = balance,
                        comment         = "Point Withdrawal in Your Current Balance",
                        username        = data.Name,
                        mobilenumber    = data1.UserName,
                        ConvertedPoints = model.PointsWithdraw
                    };
                    entities.Transactions.Add(transaction);
                    entities.SaveChanges();
                    return(new RedeemBalanceModel()
                    {
                        RedeemBalance = balance,
                        State = "True"
                    });
                }
                else
                {
                    return(new RedeemBalanceModel()
                    {
                        RedeemBalance = 0,
                        State = "insufficient"
                    });
                }
            }
            else
            {
                return(new RedeemBalanceModel()
                {
                    RedeemBalance = 0,
                    State = "Passcode"
                });
            }
        }