public List <UserModel> GetUserListModel(ListSearchModel model) { var users = userRepository.GetList(model); //todo : need to fix var roles = roleRepository.GetList(); foreach (var user in users) { user.CreatedUserModel = GetUserModel(user.CreatedUser); user.ModifiedUserModel = user.ModifiedUser == null ? null : GetUserModel(user.ModifiedUser.Value); user.RoleModel = roles.Find(x => x.Id == user.RoleId); } return(users); }
public List <UserModel> GetList(ListSearchModel model) { List <string> where = new List <string>(); if (!string.IsNullOrEmpty(model.username)) { where.Add($"UserName like '%{model.username}%'"); } if (!string.IsNullOrEmpty(model.start_date_gte)) { where.Add($"SubmitDate >= '{model.start_date_gte}'"); } if (!string.IsNullOrEmpty(model.start_date_lte)) { where.Add($"SubmitDate <= '{model.start_date_lte}'"); } if (where.Count == 0) { return(Find(null).ToList()); } FormattableString query = $"{CreateQueryString(where, "and")}"; return(Find(action => action.Where(query)).ToList()); }