示例#1
0
        public async Task <List <UserDTO> > FilterUserAsync(UserFilterModel userFilter)
        {
            List <UserDTO> list = await this.GetAllUsersAsync();

            if (userFilter.PersonId != null)
            {
                list = list.Where(emp => emp.PersonId == userFilter.PersonId).ToList();
            }
            if (userFilter.Name != null)
            {
                list = list.Where(emp => emp.Name == userFilter.Name).ToList();
            }
            if (userFilter.Surname != null)
            {
                list = list.Where(emp => emp.Surname == userFilter.Surname).ToList();
            }
            if (userFilter.Patronumic != null)
            {
                list = list.Where(emp => emp.Patronumic == userFilter.Patronumic).ToList();
            }
            if (userFilter.AddressID != null)
            {
                list = list.Where(emp => emp.AddressID == userFilter.AddressID).ToList();
            }
            if (userFilter.PhoneNumber != null)
            {
                list = list.Where(emp => emp.PhoneNumber == userFilter.PhoneNumber).ToList();
            }
            return(list);
        }
示例#2
0
        public async Task <IEnumerable <SelectOption> > SelectUsersAsync(UserFilterModel criterias)
        {
            if (criterias == null)
            {
                criterias = new UserFilterModel();
            }

            var exclusiveUserIds = new List <long>();

            if (!string.IsNullOrEmpty(criterias.ExclusiveUserIdentityId))
            {
                exclusiveUserIds.Add(await _userManager.DecryptUserIdAsync(criterias.ExclusiveUserIdentityId));
            }

            var data = await _userService.SearchAsync(new UserFilter
            {
                Page     = criterias.Page,
                PageSize = _pagerOptions.PageSize,
                Keyword  = criterias.Search,
            }, exclusiveUserIds);

            var users = await MapUsersResultToModelAsync(data);

            var userSelections = users.Select(x => new SelectOption
            {
                Id   = x.UserIdentityId,
                Text = x.DisplayName
            });

            return(userSelections);
        }
示例#3
0
        public async Task <List <UserViewDTO> > FilterUsersFullNameAsync(UserFilterModel userFilterModel)
        {
            List <UserViewDTO> list = await this.GetAllUsersViewAsync();

            if (userFilterModel.Name != "" && userFilterModel.Surname == "" && userFilterModel.Patronumic == "")
            {
                list = list.Where(x => x.Person.Name == userFilterModel.Name ||
                                  x.Person.Surname == userFilterModel.Name ||
                                  x.Person.Patronumic == userFilterModel.Name).ToList();
            }

            if (userFilterModel.Name != "" && userFilterModel.Surname != "" && userFilterModel.Patronumic == "")
            {
                list = list.Where(x => x.Person.Name == userFilterModel.Name && x.Person.Surname == userFilterModel.Surname ||
                                  x.Person.Surname == userFilterModel.Name && x.Person.Name == userFilterModel.Surname ||
                                  x.Person.Name == userFilterModel.Name && x.Person.Patronumic == userFilterModel.Surname).ToList();
            }

            if (userFilterModel.Name != "" && userFilterModel.Surname != "" && userFilterModel.Patronumic != "")
            {
                list = list.Where(x => x.Person.Name == userFilterModel.Name &&
                                  x.Person.Surname == userFilterModel.Surname &&
                                  x.Person.Name == userFilterModel.Patronumic).ToList();
            }

            return(list);
        }
示例#4
0
        private async Task LoadUsers(UserFilterModel filter, bool isAndMode)
        {
            var respond = await User.GetAll(filter, isAndMode);

            Users.AddOrUpdateAll(respond.ActiveRecords);
            Users.LastSynchronization = respond.Timestamp;
        }
        public IEnumerable <UserContact> GetByPage(int page, UserFilterModel user)
        {
            int pageSize = 10;
            int skipSize = (page - 1) * pageSize;

            //empty list, negative skip size should not return any page
            if (skipSize < 0)
            {
                return(new List <UserContact>());
            }
            //returns page or empty list if not found
            return(_context.Users
                   .Where(e => (string.IsNullOrEmpty(user.FirstName) || e.FirstName.ToLower() == user.FirstName.ToLower()) &&
                          (string.IsNullOrEmpty(user.LastName) || e.LastName.ToLower() == user.LastName.ToLower()) &&
                          (string.IsNullOrEmpty(user.Email) || e.Email.ToLower() == user.Email.ToLower()))
                   .Skip(skipSize)
                   .Take(pageSize)
                   .OrderBy(u => u.LastName)
                   .Select(p => new UserContact
            {
                Id = p.Id,
                FirstName = p.FirstName,
                LastName = p.LastName,
                Email = p.Email
            }
                           ).ToList());
        }
示例#6
0
        public PagedList <UserModel> GetUsers(UserFilterModel model)
        {
            var users  = GetAll();
            var stores = storeRepository.GetAll();

            var lst = from user in users
                      join store in stores on user.StoreId equals store.Id
                      select new UserModel {
                Userid    = user.Id,
                Username  = user.Username,
                Loginname = user.Loginname,
                Email     = user.Email,
                Storeid   = store.Id,
                Storename = store.Name,
                Created   = store.Created.Value.ToString("yyyy年MM月dd HH:mm:ss")
            };


            if (!string.IsNullOrWhiteSpace(model.UserName))
            {
                lst = lst.Where(m => m.Username.Contains(model.UserName));
            }

            if (!string.IsNullOrWhiteSpace(model.LoginName))
            {
                lst = lst.Where(m => m.Loginname.Contains(model.LoginName));
            }

            if (!string.IsNullOrWhiteSpace(model.StoreName))
            {
                lst = lst.Where(m => m.Storename.Contains(model.StoreName));
            }

            return(lst.ToPagedList(model.PageNumber, model.PageSize));
        }
示例#7
0
        public async Task <IActionResult> Index(UserFilterModel filter)
        {
            var userPageList = await _userService.GetAsync(new UserFilter
            {
                Address          = filter.Address,
                BirthDateFrom    = filter.BirthDateFrom,
                BirthDateTo      = filter.BirthDateTo,
                CountryId        = filter.CountryId,
                CreatedById      = filter.CreatedById,
                CreatedDateFrom  = filter.CreatedDateFrom,
                CreatedDateTo    = filter.CreatedDateTo,
                GenderId         = filter.GenderId,
                IsEmailConfirmed = filter.IsEmailConfirmed,
                Page             = filter.Page,
                PageSize         = _pagerOptions.PageSize,
                PhoneNumber      = filter.PhoneNumber,
                Keyword          = filter.Search,
                StatusId         = filter.StatusId,
                UpdatedById      = filter.UpdatedById,
                CanGetDeleted    = true,
                CanGetInactived  = true
            });

            var users = userPageList.Collections.Select(x => new UserModel
            {
                Address          = x.Address,
                UpdatedById      = x.UpdatedById,
                StatusId         = (UserStatus)x.StatusId,
                BirthDate        = x.BirthDate,
                CreatedById      = x.CreatedById,
                CreatedDate      = x.CreatedDate,
                CountryCode      = x.CountryCode,
                CountryId        = x.CountryId,
                CountryName      = x.CountryName,
                Description      = x.Description,
                DisplayName      = x.DisplayName,
                Email            = x.Email,
                Firstname        = x.Firstname,
                Lastname         = x.Lastname,
                GenderId         = x.GenderId,
                GenderLabel      = x.GenderLabel,
                Id               = x.Id,
                IsEmailConfirmed = x.IsEmailConfirmed,
                PhoneNumber      = x.PhoneNumber,
                UpdatedDate      = x.UpdatedDate
            });
            var userPage = new PageListModel <UserModel>(users)
            {
                Filter      = filter,
                TotalPage   = userPageList.TotalPage,
                TotalResult = userPageList.TotalResult
            };

            if (_httpHelper.IsAjaxRequest(Request))
            {
                return(PartialView("_UserTable", userPage));
            }

            return(View(userPage));
        }
        public ActionResult NewUser(UserModel user, UserFilterModel filter)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    EmployeeServices.CreateUser(user);
                    return(RedirectToAction("UserListing", filter.GenerateUserAccessRoute()));
                }
            }
            catch (Exception ex)
            {
                Logger.Error(ex.ToString());
                ModelState.AddModelError(String.Empty, Constants.ServerError);
            }

            // Invalid - redisplay with errors
            var model = new UserDetailModel()
            {
                Action = "NewUser",
                User   = user,
                Filter = filter,
                Roles  = LookupServices.GetRoleOptions(user.RoleName)
            };

            ViewBag.Locations = LocationServices.GetLocationLookup(true, -1);
            return(View("UserDetail", model));
        }
示例#9
0
        public IEnumerable <User> GetBy(UserFilterModel filterModel)
        {
            if (filterModel == null)
            {
                throw new ArgumentNullException(nameof(filterModel));
            }

            ExpressionStarter <JToken> filterBuilder = PredicateBuilder.New <JToken>();

            if (!string.IsNullOrEmpty(filterModel.Id))
            {
                filterBuilder.And(x => x["Id"].ToString() == filterModel.Id);
            }

            if (!string.IsNullOrEmpty(filterModel.Email))
            {
                filterBuilder.And(x => x["Email"].ToString() == filterModel.Email);
            }

            if (filterModel.ToDate.HasValue)
            {
                filterBuilder.And(x => x["Birthday"].Value <DateTime>() <= filterModel.ToDate.Value);
            }

            IEnumerable <User> dataEntities = _dataContext.Items.Value
                                              .Where(filterBuilder)
                                              .Select(x => x.ToObject <User>());

            return(dataEntities ?? Enumerable.Empty <User>());
        }
示例#10
0
        public ResponsePackage <List <UserDTO> > FilterUsersRecord(UserFilterModel userFilterModel)
        {
            List <UserDTO> list = GetAllEmployee().Result;



            if (userFilterModel.Name != "" && userFilterModel.Surname == "" && userFilterModel.Patronumic == "")
            {
                list = list.Where(x => x.Name == userFilterModel.Name ||
                                  x.Surname == userFilterModel.Name ||
                                  x.Patronumic == userFilterModel.Name).ToList();
            }

            if (userFilterModel.Name != "" && userFilterModel.Surname != "" && userFilterModel.Patronumic == "")
            {
                list = list.Where(x => x.Name == userFilterModel.Name && x.Surname == userFilterModel.Surname ||
                                  x.Surname == userFilterModel.Name && x.Patronumic == userFilterModel.Surname ||
                                  x.Name == userFilterModel.Name && x.Patronumic == userFilterModel.Surname).ToList();
            }

            if (userFilterModel.Name != "" && userFilterModel.Surname != "" && userFilterModel.Patronumic != "")
            {
                list = list.Where(x => x.Name == userFilterModel.Name &&
                                  x.Surname == userFilterModel.Surname &&
                                  x.Name == userFilterModel.Patronumic).ToList();
            }

            return(new ResponsePackage <List <UserDTO> >()
            {
                Result = list
            });
        }
示例#11
0
        public JsonResult List(UserFilterModel filterModel)
        {
            var model  = usersListModelBuilder.Build(filterModel, true);
            var result = Json(model, JsonRequestBehavior.AllowGet);

            return(result);
        }
示例#12
0
        public ActionResult IndexAjax(UserFilterModel filter)
        {
            var userQuery = this._dbContext.Users.Include(u => u.Pings).AsQueryable();

            if (!string.IsNullOrWhiteSpace(filter.FullName))
            {
                userQuery = userQuery.Where(p => (p.FirstName + " " + p.LastName).Contains(filter.FullName));
            }

            var allUsers = userQuery.ToList();

            List <User> users = new List <User>();

            foreach (var user in allUsers)
            {
                var friendships = this._dbContext.Friendships.Where(f => f.Receiver.Id == user.Id || f.Sender.Id == user.Id);

                if (friendships.Count() == 0)
                {
                    continue;
                }

                // Skip yourself
                if (user.Id == UserId)
                {
                    continue;
                }

                users.Add(user);
            }

            var model = users.ToList();

            return(PartialView("_FriendList", model));
        }
示例#13
0
        public IEnumerable <UserViewModel> GetUsers(UserFilterModel filter)
        {
            var users     = _repositoryManager.Users.GetAll();
            var locations = _repositoryManager.Locations.GetAll();

            users = filter.Filter(users);

            var usersList = from u in users
                            join l in locations on u.LocationId equals l.Id
                            select new UserViewModel
            {
                Id = u.Id,
                DescriptionHeader = u.DescriptionHeader,
                Firstname         = u.Firstname,
                Lastname          = u.Lastname,
                HourlyRate        = u.HourlyRate,
                TotalEarned       = u.TotalEarned,
                Location          = new LocationModel
                {
                    Id      = l.Id,
                    Country = l.Country
                }
            };

            return(usersList);
        }
示例#14
0
        GetUsersAsync(UserFilterModel filter)
        {
            if (filter == null)
            {
                throw new ArgumentNullException(nameof(filter));
            }

            IQueryable <ApplicationUser> users = _userManager.Users;

            if (!string.IsNullOrEmpty(filter.Name))
            {
                users = users.Where(u => u.UserName.Contains(filter.Name) ||
                                    u.LastName.Contains(filter.Name) ||
                                    u.FirstName.Contains(filter.Name));
            }

            int total = users.Count();

            users = users.OrderBy(u => u.UserName);

            List <UserWithRoles <ApplicationUser> > results = new List <UserWithRoles <ApplicationUser> >();

            foreach (ApplicationUser user in users.Skip(filter.GetSkipCount())
                     .Take(filter.PageSize == 0 ? total : filter.PageSize))
            {
                UserWithRoles <ApplicationUser> result = await GetUserWithRolesAsync(user);

                results.Add(result);
            }

            return(new DataPage <UserWithRoles <ApplicationUser> >(
                       filter.PageNumber, filter.PageSize, total, results));
        }
        public async Task <IEnumerable <User> > GetUsers(int portalId, UserFilterModel filters = null)
        {
            IQueryable <User> users = Context.Users.Where(x => x.PortalId == portalId && !x.IsDeleted);

            if (filters == null)
            {
                return(await users.ToListAsync());
            }
            {
                if (!string.IsNullOrEmpty(filters.FirstName))
                {
                    users = users.Where(x => x.FirstName.ToLower().Contains(filters.FirstName.Trim().ToLower()));
                }

                if (!string.IsNullOrEmpty(filters.LastName))
                {
                    users = users.Where(x => x.LastName.ToLower().Contains(filters.LastName.Trim().ToLower()));
                }

                if (!string.IsNullOrEmpty(filters.EmailAddress))
                {
                    users = users.Where(x => x.EmailAddress.ToLower().Contains(filters.EmailAddress.Trim().ToLower()));
                }

                if (filters.IsActive != null)
                {
                    users = users.Where(x => x.IsActive == filters.IsActive.Value);
                }
            }

            return(await users.ToListAsync());
        }
        public ActionResult EditUser(int id, UserFilterModel filter, FormCollection collection)
        {
            var user = EmployeeServices.GetUser(id);

            try
            {
                UpdateModel(user, "User");
                EmployeeServices.UpdateUser(user);

                return(RedirectToAction("UserListing", filter.GenerateUserAccessRoute()));
            }
            catch (Exception ex)
            {
                // Invalid - redisplay with errors
                Logger.Error(ex.ToString());
                ModelState.AddModelError(String.Empty, Constants.ServerError);
                var model = new UserDetailModel()
                {
                    Action = "EditUser",
                    User   = user,
                    Filter = filter,
                    Roles  = LookupServices.GetRoleOptions(user.RoleName)
                };

                ViewBag.Locations = LocationServices.GetLocationLookup(true, model.User.LocationId);
                return(View("UserDetail", model));
            }
        }
示例#17
0
        public ViewResult Index(UserFilterModel filterModel)
        {
            var model = usersListModelBuilder.Build(filterModel, true);

            var result = View("WaitForRequest", model);

            return(result);
        }
示例#18
0
        public ServiceResponse <List <User> > GetAllOrderByDescendingLastLoginDate(UserFilterModel filter)
        {
            var response = new ServiceResponse <List <User> >();

            response.IsSucceeded     = true;
            response.RecordsTotal    = userRepository.ListQueryable.Count();
            response.RecordsFiltered = userRepository.ListQueryable.AddSearchFilters(filter).Count();
            response.Result          = userRepository.ListQueryable.AddSearchFilters(filter).AddOrderAndPageFilters(filter).ToList();
            return(response);
        }
 public IActionResult GetUsersByPage([FromQuery] int page, [FromQuery] UserFilterModel user)
 {
     try
     {
         return(Ok(_userBusiness.PagedUsers(page, user)));
     }
     catch
     {
         throw;
     }
 }
        public IHttpActionResult userList(UserFilterModel filter)
        {
            var filtermodel = Mapping.UserMapping.GetUserListFilter(filter);
            var users       = Mapping.UserMapping.GetUserList(userService.GetUserListModel(filtermodel));

            return(Content(HttpStatusCode.OK, new BaseResult <List <UserListViewModel> >()
            {
                success = true,
                data = users
            }));
        }
示例#21
0
 public static RouteValueDictionary GenerateUserAccessRoute(this UserFilterModel model, int?page = null)
 {
     return(new RouteValueDictionary()
     {
         { "Page", (page.HasValue) ? page.Value.ToString() : model.Page.ToString() },
         { "Size", model.Size.ToString() },
         { "Name", model.Name },
         { "Role", model.Role },
         { "HasSiteAccess", model.HasSiteAccess }
     });
 }
示例#22
0
        public ISpecification <T> UsersByFilter <T>(UserFilterModel filter) where T : User
        {
            var keywords = filter.Keywords;
            ISpecification <T> userSpec;

            if (keywords == null)
            {
                userSpec = Specification <T> .All();
            }
            else
            {
                userSpec = Specification <T> .Start(
                    t => keywords.All(
                        kw => kw == null || kw.Trim() == string.Empty ||
                        (t.Username != null && t.Username.Contains(kw)) ||
                        (t.First != null && t.First.Contains(kw)) ||
                        (t.Last != null && t.Last.Contains(kw))), keywords);
            }
            if (filter.Type == UserFilterModel.UserFilterType.Keywords)
            {
                return(userSpec);
            }
            else if (filter.Type == UserFilterModel.UserFilterType.Username)
            {
                var username = filter.Username;
                return(Specification <T> .Start((T t) => username == t.Username, username));
            }
            else if (filter.Type == UserFilterModel.UserFilterType.RoleAndKeywords)
            {
                var roleId = filter.RoleId;
                var role   = Specification <T> .Start(t => roleId == 0 || t.UserRoles.Any(ur => ur.RoleId == roleId), roleId);

                return(userSpec.And(role));
            }
            else if (filter.Type == UserFilterModel.UserFilterType.AnyRoleAndKeywords)
            {
                if (filter.RoleIds == null)
                {
                    return(userSpec);
                }

                var role = Specification <T> .None();

                foreach (var roleId in filter.RoleIds)
                {
                    role = role.Or(u => u.UserRoles.Any(ur => ur.RoleId == roleId));
                }

                userSpec.Metadata = filter.RoleIds;
                return(userSpec.And(role));
            }
            throw new NotImplementedException($"User filter type {filter.Type} has not been implemented.");
        }
示例#23
0
 public static RouteValueDictionary GenerateUserAccessRouteForEdit(this UserFilterModel model, int id)
 {
     return(new RouteValueDictionary()
     {
         { "id", id.ToString() },
         { "Page", model.Page.ToString() },
         { "Size", model.Size.ToString() },
         { "Name", model.Name },
         { "Role", model.Role },
         { "HasSiteAccess", model.HasSiteAccess }
     });
 }
示例#24
0
        public IEnumerable <User> FilterUser(UserFilterModel model)
        {
            var result = context.Users.ToList();

            if (model.Department != null)
            {
                result = result.Where(s => s.Department == model.Department).ToList();
            }
            if (model.Position != null)
            {
                result = result.Where(s => s.Position == model.Position).ToList();
            }
            return(result);
        }
示例#25
0
        public async Task <PageModel <UserModel> > GetPage(PageModel model, UserFilterModel filter = null)
        {
            var query = _context.Users
                        .Include(x => x.Role)
                        .Include(x => x.Avatar)
                        .AsQueryable();

            if (filter != null)
            {
                if (!string.IsNullOrEmpty(filter.Search))
                {
                    query = query.Where(x =>
                                        x.Name.ToUpper().Contains(filter.Search.ToUpper()) ||
                                        x.Email.ToUpper().Contains(filter.Search.ToUpper()));
                }

                if (filter.UserStatus != null)
                {
                    query = query.Where(x => x.Status == filter.UserStatus.Value);
                }

                if (filter.IncludeDeleted != true)
                {
                    query = query.Where(x => !x.IsDeleted);
                }

                if (filter.IncludeAdmin != true)
                {
                    query = query.Where(x => x.RoleId != RoleGuid.Admin);
                }
            }

            var total = await query.CountAsync();

            var items = await query
                        .OrderBy(x => x.Name)
                        .GetPage(model)
                        .ToListAsync();

            var result = new PageModel <UserModel>
            {
                Page     = model.Page,
                PageSize = model.PageSize,
                Total    = total,
                Items    = items
            };

            return(result);
        }
        public ActionResult NewUser(UserFilterModel filter)
        {
            var model = new UserDetailModel()
            {
                Action = "NewUser",
                User   = new UserModel(),
                Filter = filter,
                Roles  = LookupServices.GetRoleOptions("Employee")
            };

            model.User.PasswordString = PasswordGenerator.GeneratePassword();

            ViewBag.Locations = LocationServices.GetLocationLookup(true, -1);
            return(View("UserDetail", model));
        }
示例#27
0
        public static FilterModel <DataAccess.Entities.User> MapToEFFilterModel(this UserFilterModel filterBL)
        {
            var filterDAL = new FilterModel <DataAccess.Entities.User>();

            filterDAL.SortProperty = filterBL.SortProperty;
            filterDAL.IsAscending  = filterBL.IsAscending;
            filterDAL.StartIndex   = filterBL.StartIndex;
            filterDAL.Quantity     = filterBL.Quantity;

            filterDAL.Predicate = user => (string.IsNullOrWhiteSpace(filterBL.SearchQuery) || (user.FirstName + " " + user.LastName).ToLower().Contains(filterBL.SearchQuery.ToLower())) &&
                                  (filterBL.LockStatuses != null && filterBL.LockStatuses.Count > 0 && filterBL.LockStatuses.Any(s => s == user.LockoutEnabled)) &&
                                  (!user.isRemoved);

            return(filterDAL);
        }
示例#28
0
        public async Task <(IEnumerable <User>, int)> GetFilteredUsersAsync(UserFilterModel model, PaginationFilterModel pagination)
        {
            var result = await _dbSet
                         .Where(user => model.UserName == null || EF.Functions.Like(user.FirstName, $"%{model.UserName}%") || EF.Functions.Like(user.LastName, $"%{model.UserName}%"))
                         .Where(user => model.IsBlocked == null || user.IsBlocked == model.IsBlocked)
                         .ToListAsync();

            int countElement = result.Count();

            result = result.Skip((pagination.PageNumber - Constants.Page.PAGE_NUMBER) * pagination.PageSize).Take(pagination.PageSize).ToList();

            (IEnumerable <User>, int)tupleResult = (result, countElement);

            return(tupleResult);
        }
        public ActionResult EditUser(int id, UserFilterModel filter)
        {
            var user = EmployeeServices.GetUser(id);

            var model = new UserDetailModel()
            {
                Action = "EditUser",
                User   = user,
                Filter = filter,
                Roles  = LookupServices.GetRoleOptions(user.RoleName)
            };

            ViewBag.Locations = LocationServices.GetLocationLookup(true, model.User.LocationId);
            return(View("UserDetail", model));
        }
示例#30
0
        public static List <UserModel> GetUsersFiltered(UserFilterModel filter)
        {
            using (var ctx = new DFAppEntities())
            {
                IQueryable <DBModel.Users> query = ctx.Users.Where(x => x.Username.ToLower() != "mdarco");

                if (filter != null && filter.Username != null && filter.Username.Trim().Length != 0)
                {
                    query = query.Where(u => u.Username.Contains(filter.Username.Trim()));
                }

                if (filter != null && filter.FirstName != null && filter.FirstName.Trim().Length != 0)
                {
                    query = query.Where(u => u.FirstName.Contains(filter.FirstName.Trim()));
                }

                if (filter != null && filter.LastName != null && filter.LastName.Trim().Length != 0)
                {
                    query = query.Where(u => u.LastName.Contains(filter.LastName.Trim()));
                }

                return(query.Select(u =>
                                    new UserModel()
                {
                    UserID = u.UserID,
                    Username = u.Username,
                    FirstName = u.FirstName,
                    LastName = u.LastName,
                    FullName = u.FirstName + " " + u.LastName,
                    IsActive = u.IsActive,

                    UserGroups =
                        u.UserGroupMembers.Select(ugm =>
                                                  new UserGroupModel()
                    {
                        UserGroupID = ugm.UserGroupID,
                        UserGroupName = ugm.UserGroups.UserGroupName
                    }
                                                  )
                        .OrderBy(ug => ug.UserGroupName)
                        .ToList()
                }
                                    )
                       .OrderBy(u => u.FullName)
                       .ThenBy(u => u.LastName)
                       .ToList());
            }
        }