Пример #1
0
        public JsonResult GetMasterUsersListsOnScroll()
        {
            List <NewUserVM> objList       = new List <NewUserVM>();
            List <UserModel> userModelList = new List <UserModel>();
            string           cacheName     = "users-matches-" + DateTime.Now.Date.ToString("MM-dd-yyyy") + "-";

            if (!_cache.TryGetValue(cacheName, out userModelList))
            {
                if (userModelList == null)
                {
                    userModelList = _IBOUsers.GetMasterUsers();
                }

                // cache memory
                if (userModelList != null && userModelList.Count > 0)
                {
                    var cacheEntryOptions = new MemoryCacheEntryOptions().SetAbsoluteExpiration(DateTime.Now.AddMinutes(5));
                    // Save data in cache.
                    _cache.Set(cacheName, userModelList, cacheEntryOptions);
                }
            }
            userModelList.ForEach(item =>
            {
                NewUserVM uvm = new NewUserVM
                {
                    userName     = item.userName,
                    userEmail    = item.userEmail,
                    userPhone    = item.userPhone,
                    userPwd      = item.userPwd,
                    userId       = item.userId,
                    countryName  = item.countryName,
                    provinceName = item.provinceName,
                    IsVerified   = item.IsVerified
                };
                objList.Add(uvm);
            });
            objList = objList.Skip((_PageNumber - 1) * 10).Take(10).ToList();
            _PageNumber++;

            //if (objList == null)
            //{
            //    _PageNumber = 1;

            //}
            //var obj = objList;
            return(Json(objList, new JsonSerializerSettings()));
        }
        public JsonResult GetMasterUsersLists()
        {
            //var sa = new JsonSerializerSettings();
            var list = _IBOUsers.GetMasterUsers();
            List<NewUserVM> objList = new List<NewUserVM>();
            foreach (var item in list)
            {
                NewUserVM uvm = new NewUserVM();
                uvm._userName = item.userName;
                uvm._userEmail = item.userEmail;
                uvm._userPhone = item.userPhone;
                uvm._userPwd = item.userPwd;
                uvm._userId = item.userId;

                objList.Add(uvm);


            }
            var obj = objList;
            return Json(obj, new JsonSerializerSettings());
        }