コード例 #1
0
        public async Task <IActionResult> Logons(DataSourceRequest command,
                                                 LogonListModel model)
        {
            var(logonModelList, totalCount) = await _logonViewModelService.PrepareLogonListModel(model, command.Page,
                                                                                                 command.PageSize);

            var gridModel = new DataSourceResult
            {
                Data  = logonModelList,
                Total = totalCount
            };

            return(Json(gridModel));
        }
コード例 #2
0
        public async Task <LogonListModel> PrepareLogonListModel()
        {
            var model = new LogonListModel();

            //UserType
            model.AvailableUserType.Add(new SelectListItem {
                Text = "All", Value = "0"
            });
            foreach (var u in (await _userService.GetAllUserType((int)_workContext.CurrentCustomer.UserType, (int)_workContext.CurrentCustomer.ClientId)))
            {
                model.AvailableUserType.Add(new SelectListItem {
                    Text = u.Definition, Value = u.UserType.ToString()
                });
            }

            return(model);
        }
コード例 #3
0
        public async Task <(IEnumerable <LogonModel> logonModelList, int totalCount)> PrepareLogonListModel(LogonListModel model,
                                                                                                            int pageIndex = 0, int pageSize = 1000)
        {
            var Logons = await _userService.GetAllLogons((int)_workContext.CurrentCustomer.ClientId, (int)_workContext.CurrentCustomer.UserType, model.SearchUserType, (int)_workContext.CurrentCustomer.LogonId, 0);

            int totalCount = Logons.Count;
            int pageOffSet = (Convert.ToInt32(pageIndex) - 1) * 10;

            Logons = Logons.Skip(pageOffSet).Take(Convert.ToInt32(pageSize)).ToList();

            var userTypeList = await _userService.GetAllUserType((int)_workContext.CurrentCustomer.UserType, (int)_workContext.CurrentCustomer.ClientId);

            ///Add from store procedure response to model
            var logonListModel = new List <LogonModel>();

            foreach (var l in Logons)
            {
                logonListModel.Add(new LogonModel
                {
                    LogonId          = l.LogonId,
                    UserName         = l.UserName,
                    EMail            = l.email,
                    UserTypeSting    = userTypeList.Where(u => u.UserType == l.UserType).Select(u => u.Definition).FirstOrDefault().ToString(),
                    Password         = l.Password,
                    LastLoginDate    = l.LogDate,
                    LogonCount       = l.LogonCount,
                    ServiceContracts = (bool)l.ServiceContracts
                });
            }

            return(logonListModel, totalCount);
        }