예제 #1
0
        public ActionResult UserCreditLogGrid()
        {
            List <UserCreditLogGridViewModel> retData = new List <UserCreditLogGridViewModel>();
            var userCreditLogs = userCreditLogsService.GetAllUserCreditLogs().Where(x => x.UserId == CurrentLoggedInUser.Id).ToList();
            int iCount         = 0;

            foreach (var u in userCreditLogs)
            {
                iCount += 1;
                retData.Add(new UserCreditLogGridViewModel()
                {
                    SNo                = iCount,
                    Id                 = u.Id,
                    Date               = u.CreatedAt.ToString("dd-MMM-yyyy hh:mm:ss tt"),
                    CreatedAt          = u.CreatedAt,
                    Credits            = LeadsHelpers.ToUsNumberFormat(u.Credits),
                    DisCountPercentage = u.DiscountPercentage.ToString(),
                    AmountPaid         = Math.Round(u.FinalAmount, 2).ToString(),
                    PackageName        = creditPackageService.GetAllCreditPackages().FirstOrDefault(x => x.Id == u.PackageId).PackageName
                });
            }
            var usersRefered       = userService.GetUsers().Where(x => x.ReferedUserId.HasValue && x.ReferedUserId.Value == CurrentLoggedInUser.Id).ToList();
            var referalCreditsList = userCreditLogsService.GetAllUserCreditLogs().ToList().Where(x => usersRefered.Select(y => y.Id).Contains(x.UserId));

            foreach (var u in referalCreditsList)
            {
                iCount += 1;
                var thisUser = usersRefered.Where(x => x.Id == u.UserId).FirstOrDefault();
                retData.Add(new UserCreditLogGridViewModel()
                {
                    SNo                = iCount,
                    Id                 = u.Id,
                    Date               = u.CreatedAt.ToString("dd-MMM-yyyy hh:mm:ss tt"),
                    CreatedAt          = u.CreatedAt,
                    Credits            = LeadsHelpers.ToUsNumberFormat(u.ReferalUserCredits),
                    DisCountPercentage = "-",
                    AmountPaid         = "-",
                    PackageName        = "Referral Bonus From " + thisUser.Name
                });
            }

            retData = retData.OrderByDescending(x => x.CreatedAt).ToList();
            var jsonData = new { data = from emp in retData select emp };

            return(new JsonResult()
            {
                Data = jsonData,
                JsonRequestBehavior = JsonRequestBehavior.AllowGet,
                MaxJsonLength = Int32.MaxValue
            });
        }
예제 #2
0
        public ActionResult UserCreditLogsGrid(DateTime date)
        {
            List <UserCreditLogGridViewModel> retData = new List <UserCreditLogGridViewModel>();
            var userCreditLogs = userCreditLogsService.GetAllUserCreditLogs().ToList().Where(x => x.CreatedAt.Date == date.Date);
            var users          = userService.GetUsers().ToList();
            int iCount         = 0;

            foreach (var u in userCreditLogs)
            {
                var    thisUser       = users.Where(x => x.Id == u.UserId).FirstOrDefault();
                string ReferalDetails = string.Empty;
                if (thisUser.ReferedUserId.HasValue && thisUser.ReferedUserId.Value > 0)
                {
                    ReferalDetails = string.Format("Referral Bonus {0} to {1}", LeadsHelpers.ToUsNumberFormat(u.ReferalUserCredits), users.Where(x => x.Id == thisUser.ReferedUserId.Value).FirstOrDefault().Name);
                }
                iCount += 1;
                retData.Add(new UserCreditLogGridViewModel()
                {
                    SNo                = iCount,
                    Id                 = u.Id,
                    UserName           = thisUser.Name,
                    Date               = u.CreatedAt.ToString("dd-MMM-yyyy hh:mm:ss tt"),
                    CreatedAt          = u.CreatedAt,
                    Credits            = LeadsHelpers.ToUsNumberFormat(u.Credits),
                    DisCountPercentage = u.DiscountPercentage.ToString(),
                    AmountPaid         = Math.Round(u.FinalAmount, 2).ToString(),
                    PackageName        = creditPackageService.GetAllCreditPackages().FirstOrDefault(x => x.Id == u.PackageId).PackageName,
                    ReferalInfo        = ReferalDetails
                });
            }
            retData = retData.OrderByDescending(x => x.CreatedAt).ToList();
            var jsonData = new { data = from emp in retData select emp };

            return(new JsonResult()
            {
                Data = jsonData,
                JsonRequestBehavior = JsonRequestBehavior.AllowGet,
                MaxJsonLength = Int32.MaxValue
            });
        }