public ChallangeListsModel GetChallangersList(ChallangeIdModel model)
        {
            var data = entities.Challanges.Where(x => x.ChallangeId == model.ChallangeId).ToList();
            ChallangeListsModel        challangeListsModel  = new ChallangeListsModel();
            List <ChallangesListModel> challangesListModels = new List <ChallangesListModel>();
            int TotalPoints = 0;

            foreach (var item in data)
            {
                var CLD = new ChallangesListModel();
                CLD.UserId      = item.UserId;
                CLD.ChallangeId = item.ChallangeId;
                CLD.Name        = item.Name;
                CLD.Phone       = item.Phone;
                CLD.IsAdmin     = item.IsAdmin;
                CLD.IsAccepted  = item.IsAccepted;
                CLD.IsRejected  = item.IsRejected;
                CLD.Points      = item.Points;
                TotalPoints     = Convert.ToInt32(TotalPoints + item.Points);
                challangesListModels.Add(CLD);
                if ((bool)item.IsAdmin)
                {
                    challangeListsModel.AdminPoints        = (int)item.Points;
                    challangeListsModel.MinimumEntryPoints = item.MinimumEntryPoints != null ? (int)item.MinimumEntryPoints : 0;
                }
            }
            GeneralFunctions general     = new GeneralFunctions();
            EaningHeadModel  Challangers = new EaningHeadModel();

            Challangers = general.getEarningHeads();
            challangeListsModel.challangesLists        = challangesListModels;
            challangeListsModel.TotalPoints            = TotalPoints;
            challangeListsModel.MinimumChallangerUsers = Challangers.MinimumChallangerUsers;
            return(challangeListsModel);
        }
        public AddUserModel AddedUserList(ChallangeModel model)
        {
            var                data                = entities.Challanges.Where(x => x.ChallangeId == model.ChallangeId).ToList();
            AddUserModel       addUser             = new AddUserModel();
            List <SearchModel> ChallangesListModel = new List <SearchModel>();

            foreach (var item in data)
            {
                var Challangers = entities.Challanges.Where(x => x.ChallangeId == model.ChallangeId && x.UserId == item.UserId).FirstOrDefault();
                var CLD         = new SearchModel();
                CLD.UserID = item.UserId;
                CLD.Name   = item.Name;
                CLD.Phone  = item.Phone;
                if (Challangers != null)
                {
                    CLD.Status = true;
                }
                else
                {
                    CLD.Status = false;
                }
                ChallangesListModel.Add(CLD);
            }
            GeneralFunctions general    = new GeneralFunctions();
            EaningHeadModel  eaningHead = new EaningHeadModel();

            eaningHead       = general.getEarningHeads();
            addUser.AddUsers = ChallangesListModel;
            addUser.MinimumChallangerUsers = eaningHead.MinimumChallangerUsers;
            return(addUser);
        }
예제 #3
0
        public EaningHeadModel getEarningHeads()
        {
            var             jsonFilePath = Path.Combine(HttpRuntime.AppDomainAppPath, "Models/JsonFile/LevelEarningMasterUser.json");
            EaningHeadModel earningHeads = new EaningHeadModel();

            using (StreamReader r = new StreamReader(jsonFilePath))
            {
                string json = r.ReadToEnd();
                earningHeads = JsonConvert.DeserializeObject <EaningHeadModel>(json);
            }
            return(earningHeads);
        }
예제 #4
0
        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"
                });
            }
        }
예제 #5
0
        public TokenResult RegisterUser(RegisterBindingModel model)
        {
            try
            {
                var Otp = GeneralFunctions.GetOTP();

                //Set By Defaulte Admin Refferal Code When User Not Use Any Refferal Code
                if (model.UsedReferalCode == null || model.UsedReferalCode == "" || model.UsedReferalCode == string.Empty)
                {
                    string AdminId = ConfigurationManager.AppSettings["Admin"].ToString();
                    model.UsedReferalCode = ConfigurationManager.AppSettings["RefferalCode"].ToString();
                }

                var ParentIDs = GetParentsIDsFromReferalCode(model.UsedReferalCode, model.UserId);

                using (QuizAppEntities entities = new QuizAppEntities())
                {
                    User registerUser = new User()
                    {
                        Name            = model.Name,
                        Password        = model.Password,
                        UserID          = model.UserId,
                        CreatedDate     = DateTime.UtcNow.AddHours(5.00).AddMinutes(30.00),
                        LastUpdateDate  = DateTime.UtcNow.AddHours(5.00).AddMinutes(30.00),
                        ReferalCode     = GeneralFunctions.GetReferalCode(),
                        DeviceID        = model.DeviceID,
                        IP              = model.IP,
                        isActive        = true,
                        isBlocked       = false,
                        NotificationKey = model.NotificationKey,
                        otp             = Otp.ToString(),
                        ParentIDs       = ParentIDs,
                        Platform        = model.Platform,
                        UsedReferalCode = model.UsedReferalCode.ToLower(),
                    };
                    var       OtpSend   = sms_api_callAsync(model.PhoneNumber, Otp.ToString());
                    MobileOTP mobileOTP = new MobileOTP()
                    {
                        PhoneNumber = model.PhoneNumber,
                        OTP         = Otp,
                        CreatedDate = DateTime.UtcNow.AddHours(5.00).AddMinutes(30.00)
                    };

                    entities.MobileOTPs.Add(mobileOTP);
                    entities.Users.Add(registerUser);
                    int updatedRow = entities.SaveChanges();
                    var UserId     = registerUser.UserID;

                    if (updatedRow >= 1)
                    {
                        //Add Registration Income
                        var             jsonFilePath = HttpContext.Current.Server.MapPath("~/Models/JsonFile/LevelEarningMasterUser.json");
                        EaningHeadModel earningHeads = new EaningHeadModel();
                        using (StreamReader r = new StreamReader(jsonFilePath))
                        {
                            string json = r.ReadToEnd();
                            earningHeads = JsonConvert.DeserializeObject <EaningHeadModel>(json);
                        }
                        var data = (from U in entities.Users
                                    join A in entities.AspNetUsers on U.UserID equals A.Id where U.UserID == UserId
                                    select new UserTransactionModel()
                        {
                            UserName = U.Name,
                            MobileNumber = A.UserName
                        }).FirstOrDefault();
                        var         uniqueKey   = $"{UserId}~{DateTime.UtcNow.AddHours(5.00).AddMinutes(30.00).ToString("dd-MM-yyy")}~Earning";
                        Transaction transaction = new Transaction()
                        {
                            UserID = UserId,
                            transactionDateTime = DateTime.UtcNow.AddHours(5.00).AddMinutes(30.00),
                            UniqueKey           = uniqueKey,
                            paymentStatus       = "Earning",
                            amount       = earningHeads.RegistrationIncome,
                            comment      = "Registration Income Amount",
                            username     = data.UserName,
                            mobilenumber = data.MobileNumber
                        };
                        entities.Transactions.Add(transaction);
                        entities.SaveChanges();

                        AuthRepository authRepository = new AuthRepository();
                        return(authRepository.GenerateToken(model.PhoneNumber, model.Password, model.UserId, ""));
                    }
                    else
                    {
                        TokenResult result = new TokenResult();
                        result.result        = false;
                        result.error_message = "User registration failed.";
                        return(result);
                    }
                }
            }
            catch (Exception ex)
            {
                TokenResult result = new TokenResult();
                result.result        = false;
                result.error_message = ex.Message;
                return(result);
            }
        }
예제 #6
0
        public WithdrawalAmountBalance WithdrawalAmount(WithdrawalAmountModel model)
        {
            var             jsonFilePath = HttpContext.Current.Server.MapPath("~/Models/JsonFile/LevelEarningMasterUser.json");
            EaningHeadModel earningHeads = new EaningHeadModel();

            using (StreamReader r = new StreamReader(jsonFilePath))
            {
                string json = r.ReadToEnd();
                earningHeads = JsonConvert.DeserializeObject <EaningHeadModel>(json);
            }

            WithdrawalAmountBalance withdrawal = new WithdrawalAmountBalance();
            string passcode = entities.Users.Where(x => x.UserID == model.UserId && 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();
                if (data.CurrentBalance >= model.amount)
                {
                    var uniqueKey = $"{data.UserID}~{DateTime.UtcNow.AddHours(5.00).AddMinutes(30.00).ToString("dd-MM-yyy")}~Earning";
                    if (model.WithdrawType == "Bank")
                    {
                        if (earningHeads.MaximumWithdrawLimit >= model.amount && model.amount >= earningHeads.BankMinimumWithdrawlLimit)
                        {
                            //var WithdrawalAmount = model.amount - earningHeads.WithdrawCharges;

                            if (model.AccountNumber != null && model.NameInAccount != null && model.IFSCCode != null && model.Bank != null && model.amount.ToString() != null)
                            {
                                //Entery in Transaction Table for Withdrawal Amount in Bank
                                Transaction transaction = new Transaction()
                                {
                                    UserID = model.UserId,
                                    transactionDateTime = DateTime.UtcNow.AddHours(5.00).AddMinutes(30.00),
                                    UniqueKey           = uniqueKey,
                                    paymentStatus       = "Pending",
                                    amount               = model.amount,
                                    comment              = "Withdrawal Amount in Bank",
                                    username             = data.Name,
                                    mobilenumber         = data1.UserName,
                                    WithdrawType         = model.WithdrawType,
                                    PaytmWithdrawCharges = earningHeads.WithdrawCharges,
                                    AccountNumber        = model.AccountNumber,
                                    NameInAccount        = model.NameInAccount,
                                    Bank     = model.Bank,
                                    IFSCCode = model.IFSCCode
                                };
                                entities.Transactions.Add(transaction);
                                //entities.Transactions.Add(charges);
                                entities.SaveChanges();
                                withdrawal = new WithdrawalAmountBalance()
                                {
                                    State   = "True",
                                    Balance = model.amount,
                                    status  = "Pending"
                                };
                            }
                            else
                            {
                                withdrawal = new WithdrawalAmountBalance()
                                {
                                    State   = "Bankinsufficient",
                                    Balance = model.amount
                                };
                            }
                        }
                        else
                        {
                            withdrawal = new WithdrawalAmountBalance()
                            {
                                State   = "model",
                                Balance = model.amount
                            };
                        }
                    }
                    else if (model.WithdrawType == "Paytm")
                    {
                        if (earningHeads.MaximumWithdrawLimit >= model.amount && model.amount >= earningHeads.PaytmMinimumWithdrawlLimit)
                        {
                            string      pay         = "Pending";
                            Transaction transaction = new Transaction()
                            {
                                UserID = model.UserId,
                                transactionDateTime = DateTime.UtcNow.AddHours(5.00).AddMinutes(30.00),
                                UniqueKey           = uniqueKey,
                                paymentStatus       = pay,
                                amount               = model.amount,
                                comment              = "Withdrawal Amount in Paytm",
                                username             = data.Name,
                                mobilenumber         = data1.UserName,
                                WithdrawType         = model.WithdrawType,
                                PaytmWithdrawCharges = earningHeads.WithdrawCharges,
                                PaytmOrderId         = "",
                                PaytmResponse        = "Pending"
                            };

                            entities.Transactions.Add(transaction);
                            entities.SaveChanges();

                            withdrawal = new WithdrawalAmountBalance()
                            {
                                State   = "True",
                                Balance = model.amount,
                                status  = "Pending"//paytmResult.status
                            };
                        }
                        else
                        {
                            withdrawal = new WithdrawalAmountBalance()
                            {
                                State   = "Paytminsufficient",
                                Balance = model.amount
                            };
                        }
                    }
                }
                else
                {
                    withdrawal = new WithdrawalAmountBalance()
                    {
                        State   = "CurrentBalance",
                        Balance = model.amount
                    };
                }
            }

            else
            {
                withdrawal = new WithdrawalAmountBalance()
                {
                    State   = "Passcode",
                    Balance = model.amount
                };
            }
            return(withdrawal);
        }