private static void ConfigureSystemPositions(IBaseRepository repository) { var positionService = new PositionService(repository); var systemRoles = EnumExtensions.GetTypedValues<SystemRole>().ToList(); var positionSearchCriteria = new PositionsSearchCriteria { WithRoles = systemRoles, OnlySystemPositions = true }; var systemPositions = positionService.FindPositions(positionSearchCriteria); foreach (var role1 in systemRoles.Where(role1 => !systemPositions.Any(x => x.SystemRole == role1))) positionService.SavePosition(new Position { Name = role1.ToString(), SystemRole = role1, SystemPosition = true }); SystemEntitiesStore.Positions = positionService.FindPositions(positionSearchCriteria).ToList(); }
public IEnumerable<Entities.Position> FindPositions(PositionsSearchCriteria searchCriteria) { return Repository.List<Entities.Position>(searchCriteria.BuildCriteria()); }
private static void ConfigureSystemAccounts(IBaseRepository repository) { var imageService = new ImageService(repository); var positionService = new PositionService(repository); var accountService = new AccountService(repository, imageService, positionService); User adminAccount; if (accountService.DefaultSystemAccount == null) { adminAccount = SystemEntitiesStore.SystemUserTemplate; adminAccount.ProfilePicture = imageService.DefaultUserProfileImage ?? SystemEntitiesStore.SystemUserProfileImageTemplate; adminAccount.ProfilePicture.Owner = adminAccount; if (accountService.SaveUser(adminAccount).InvalidValues.Any()) throw new Exception("Default system user was not created successfully"); } adminAccount = accountService.GetUserByEmailAddress(SystemEntitiesStore.SystemUserTemplate.Email); SystemEntitiesStore.User = adminAccount; SystemEntitiesStore.Address = adminAccount.Address; if (!adminAccount.Positions.Any(x => x.Position.SystemRole == SystemRole.Admin)) { var adminPositionSearchCriteria = new PositionsSearchCriteria { WithRoles = new List<SystemRole> { SystemRole.Admin }, OnlySystemPositions = true }; var adminPosition = positionService.FindPositions(adminPositionSearchCriteria).First(); positionService.SaveUserPosition(new UserPosition { Position = adminPosition, User = adminAccount }); } }
public ActionResult Index(GridOptionsModel options) { options.Column = options.Column == "Id" ? "Name" : options.Column; var searchCriteria = new PositionsSearchCriteria { Ascending = options.Ascending, OrderByProperty = options.Column }; var positions = _positionService.FindPositions(searchCriteria); var model = new PositionsModel { Data = Mapper.Map<IEnumerable<Position>, IEnumerable<PositionModel>>(positions).AsPagination(options.Page, 10), Options = options }; return View(model); }