private IForumSystemData SetupUnitOfWork(IGenericRepository<Article> articlesRepository, IList<Article> articles)
        {
            Mock.Arrange(() => articlesRepository.All())
                .Returns(() => articles.AsQueryable());

            var forumSystemData = Mock.Create<IForumSystemData>();
            Mock.Arrange(() => forumSystemData.Articles)
                .Returns(() => articlesRepository);

            return forumSystemData;
        }
Esempio n. 2
0
        public IEnumerable <IdeaViewDto> GetLastCommentedPosts()
        {
            var latestCommentsList = _commentRepo.All().
                                     OrderByDescending(p => p.CreateOn).Select(p => p.PostId).Distinct().
                                     Take(WidgetSettings.LastCommentedPostsCount).ToList();
            var dbPosts         = LatestCommentPosts(latestCommentsList);
            var postsViewModels = Mapper.Map <IEnumerable <Idea>, IEnumerable <IdeaViewDto> >(dbPosts);

            return(postsViewModels);
        }
Esempio n. 3
0
        // GET api/Artists
        public IEnumerable <ArtistServiceModel> Get()
        {
            var result = ArtistsRepository.All().Select(x => new ArtistServiceModel
            {
                Name        = x.Name,
                Country     = x.Country,
                DateOfBirth = x.DateOfBirth
            }).ToList();

            return(result);
        }
Esempio n. 4
0
        // GET api/Songs
        public IEnumerable <SongServiceModel> Get()
        {
            var result = SongsRepository.All().Select(x => new SongServiceModel
            {
                Title      = x.Title,
                Genre      = x.Genre,
                ReleasedOn = x.ReleasedOn,
                Artist     = x.Artist.Name
            }).ToList();

            return(result);
        }
Esempio n. 5
0
        // GET api/Albums
        public IEnumerable <AlbumServiceModel> Get()
        {
            var result = AlbumsRepository.All().Select(x => new AlbumServiceModel
            {
                Title      = x.Title,
                Genre      = x.Genre,
                ReleasedOn = x.ReleasedOn,
                Songs      = x.Songs.Select(s => s.Title).ToList(),
                Artists    = x.Artists.Select(a => a.Name).ToList()
            }).ToList();

            return(result);
        }
        public async Task <GetApiResourceViewModel> Handle(GetApiResourceQuery request, CancellationToken cancellationToken)
        {
            var apiResource = await _configurationRepository
                              .All <IdentityServer4.EntityFramework.Entities.ApiResource>().AsNoTracking()
                              .Where(r => r.Id == request.Id)
                              .Select(GetApiResourceViewModel.Projection)
                              .SingleAsync(cancellationToken);

            return(apiResource);
        }
Esempio n. 7
0
        public async Task <GetClientViewModel> Handle(GetClientQuery request, CancellationToken cancellationToken)
        {
            var client = await _configurationRepository
                         .All <IdentityServer4.EntityFramework.Entities.Client>().AsNoTracking()
                         .Where(c => c.Id == request.Id)
                         .Select(GetClientViewModel.Projection)
                         .SingleAsync(cancellationToken);

            return(client);
        }
        public async Task <BaseSelectResponse <GetApiResourcesViewModel> > Handle(GetApiResourcesQuery request, CancellationToken cancellationToken)
        {
            var apiResources = await _configurationRepository
                               .All <IdentityServer4.EntityFramework.Entities.ApiResource>().AsNoTracking()
                               .Select(GetApiResourcesViewModel.Projection)
                               .Skip((request.PageNumber - 1) * request.PageSize)
                               .Take(request.PageSize)
                               .ToArrayAsync();

            var apiResourcesCount = await _configurationRepository.All <IdentityServer4.EntityFramework.Entities.ApiResource>().CountAsync();

            var response = new BaseSelectResponse <GetApiResourcesViewModel>
            {
                Count  = apiResourcesCount,
                Values = apiResources
            };

            return(response);
        }
        public async Task <BaseSelectResponse <GetClientsViewModel> > Handle(GetClientsQuery request, CancellationToken cancellationToken)
        {
            var clients = await _configurationRepository
                          .All <Client>().AsNoTracking()
                          .Select(GetClientsViewModel.Projection)
                          .Skip((request.PageNumber - 1) * request.PageSize)
                          .Take(request.PageSize)
                          .ToArrayAsync();

            var clientsCount = await _configurationRepository.All <Client>().CountAsync();

            var response = new BaseSelectResponse <GetClientsViewModel>
            {
                Count  = clientsCount,
                Values = clients
            };

            return(response);
        }
Esempio n. 10
0
        public override async Task OnTick(int elapsedSeconds)
        {
            // Because order matters, update every user, aspect by aspect
            await Task.Run(() => {
                this.users = genericRepository.All <User>();

                this.UpdateGold(elapsedSeconds);

                this.SaveAllUsers();
            });
        }
        private IForumSystemData SetupUnitOfWork(IGenericRepository <Article> articlesRepository, IList <Article> articles)
        {
            Mock.Arrange(() => articlesRepository.All())
            .Returns(() => articles.AsQueryable());

            var forumSystemData = Mock.Create <IForumSystemData>();

            Mock.Arrange(() => forumSystemData.Articles)
            .Returns(() => articlesRepository);

            return(forumSystemData);
        }
        public async Task <Unit> Handle(DeleteClientCommand request, CancellationToken cancellationToken)
        {
            var deleteResult = await _configurationRepository
                               .All <Client>()
                               .Where(c => c.Id == request.Id)
                               .DeleteAsync(cancellationToken);

            if (deleteResult == 0)
            {
                throw new NotFoundException(nameof(Client), request.Id);
            }

            return(Unit.Value);
        }
Esempio n. 13
0
        public ManageRolesViewDto GetManageRoles()
        {
            var viewModel = new ManageRolesViewDto();
            var users     = _users.GetDbSet();

            viewModel.Users = Mapper.Map <IEnumerable <ApplicationUser>, IEnumerable <ApplicationUserRoleViewDto> >(users.ToList());
            foreach (var user in viewModel.Users)
            {
                user.Roles = GetUserRoles(user.Id);
            }
            viewModel.Roles = _roleRepository.All().OrderBy(r => r.Name).ToList().Select(rr =>
                                                                                         new SelectListItem
            {
                Value = rr.Name.ToString(),
                Text  = rr.Name
            }).ToList();

            return(viewModel);
        }
Esempio n. 14
0
        public TrackerSolutionQuery(IGenericRepository <Department> department)
        {
            Name = "TrackerSolutionQuery";

            #region Department
            Field <DepartmentType>(
                "department",
                arguments: new QueryArguments(
                    new QueryArgument <NonNullGraphType <IntGraphType> > {
                Name = "Id"
            }
                    ),
                resolve: context => department.FindById(context.GetArgument <int>("Id"))
                );

            Field <ListGraphType <DepartmentType> >(
                "departments",
                resolve: context => department.All()
                );
            #endregion
        }
Esempio n. 15
0
        public IActionResult List()
        {
            var candidates = _candidateRepository.All();

            if (candidates != null)
            {
                var candidateViewModel = candidates.Select(c => new CandidateViewModel
                {
                    //Person
                    Id    = c.Id,
                    Email = c.Email,
                    Name  = c.Name,
                });

                return(View(candidateViewModel));
            }
            else
            {
                return(View());
            }
        }
Esempio n. 16
0
        public IActionResult Index()
        {
            var nodes = new List <TreeViewModel>
            {
                new TreeViewModel {
                    id = "1", text = "مدیر عامل", parent = "#"
                }
            };

            var jobs = _userRepository.All().Where(x => x.Level != 0);

            foreach (var job in jobs)
            {
                nodes.Add(new TreeViewModel
                {
                    id     = job.Id.ToString(),
                    text   = job.Name,
                    parent = job.Level.ToString()
                });
            }

            ViewBag.JobsChart = JsonConvert.SerializeObject(nodes);
            return(View());
        }
 public List <Mutualiteit> GetMutualiteiten()
 {
     return(repoMutualiteit.All().ToList <Mutualiteit>());
 }
 public List <Voedingspatroon> GetVoedingspatronen()
 {
     return(repoVoedingspatroon.All().ToList <Voedingspatroon>());
 }
 public List <Relatie> GetRelaties()
 {
     return(repoRelatie.All().ToList <Relatie>());
 }
 public List <Werksituatie> GetWerkSituaties()
 {
     return(repoWerksituatie.All().ToList <Werksituatie>());
 }
 public List <Geslacht> GetGeslachten()
 {
     return(repoGeslacht.All().ToList <Geslacht>());
 }
 public async Task <IEnumerable <Department> > GetIssueTrackers()
 {
     return(departmentRepo.All());
 }
Esempio n. 23
0
 public List <Masseur> GetMasseurs()
 {
     return(repoMasseur.All().ToList <Masseur>());
 }
        public async Task <Unit> Handle(UpdateClientCommand request, CancellationToken cancellationToken)
        {
            var client = await _configurationRepository
                         .All <ID4_EF_E.Client>()
                         .Include(c => c.AllowedCorsOrigins)
                         .Include(c => c.AllowedGrantTypes)
                         .Include(c => c.AllowedScopes)
                         .Include(c => c.Claims)
                         .Include(c => c.ClientSecrets)
                         .Include(c => c.IdentityProviderRestrictions)
                         .Include(c => c.PostLogoutRedirectUris)
                         .Include(c => c.Properties)
                         .Include(c => c.RedirectUris)
                         .SingleAsync(c => c.Id == request.Id, cancellationToken);

            client.ClientSecrets.RemoveAll(s => !request.ClientSecrets.Select(rs => rs.Value.Sha256()).Contains(s.Value));
            foreach (var clientSecret in request.ClientSecrets.Distinct())
            {
                var shaSecret = clientSecret.Value.Sha256();

                var secret = client.ClientSecrets.FirstOrDefault(s => s.Value == shaSecret);
                if (secret != null)
                {
                    secret.Type        = clientSecret.Type;
                    secret.Value       = shaSecret;
                    secret.Description = clientSecret.Description;
                    secret.Expiration  = clientSecret.Expiration;
                }
                else
                {
                    client.ClientSecrets.Add(new ID4_EF_E.ClientSecret
                    {
                        Type        = clientSecret.Type,
                        Value       = shaSecret,
                        Description = clientSecret.Description,
                        Created     = DateTime.UtcNow,
                        Expiration  = clientSecret.Expiration
                    });
                }
            }

            client.Claims.RemoveAll(cc => !request.Claims.Any(rc => rc.Type == cc.Type && rc.Value == cc.Value));
            foreach (var claim in request.Claims.Distinct())
            {
                if (!client.Claims.Any(c => c.Value == claim.Value && c.Type != claim.Type))
                {
                    client.Claims.Add(new ID4_EF_E.ClientClaim
                    {
                        Type  = claim.Type,
                        Value = claim.Value
                    });
                }
            }


            client.AllowedCorsOrigins.RemoveAll(o => !request.AllowedCorsOrigins.Contains(o.Origin));
            foreach (var origin in request.AllowedCorsOrigins.Distinct())
            {
                if (!client.AllowedCorsOrigins.Any(o => o.Origin == origin))
                {
                    client.AllowedCorsOrigins.Add(new ID4_EF_E.ClientCorsOrigin {
                        Origin = origin
                    });
                }
            }

            client.AllowedGrantTypes.RemoveAll(gt => !request.AllowedGrantTypes.Contains(gt.GrantType));
            foreach (var grantType in request.AllowedGrantTypes.Distinct())
            {
                if (!client.AllowedGrantTypes.Any(gt => gt.GrantType == grantType))
                {
                    client.AllowedGrantTypes.Add(new ID4_EF_E.ClientGrantType {
                        GrantType = grantType
                    });
                }
            }

            client.AllowedScopes.RemoveAll(s => !request.AllowedScopes.Contains(s.Scope));
            foreach (var scope in request.AllowedScopes.Distinct())
            {
                if (!client.AllowedScopes.Any(s => s.Scope == scope))
                {
                    client.AllowedScopes.Add(new ID4_EF_E.ClientScope {
                        Scope = scope
                    });
                }
            }

            client.IdentityProviderRestrictions.RemoveAll(p => !request.IdentityProviderRestrictions.Contains(p.Provider));
            foreach (var provider in request.IdentityProviderRestrictions.Distinct())
            {
                if (!client.IdentityProviderRestrictions.Any(p => p.Provider == provider))
                {
                    client.IdentityProviderRestrictions.Add(new ID4_EF_E.ClientIdPRestriction {
                        Provider = provider
                    });
                }
            }

            client.PostLogoutRedirectUris.RemoveAll(p => !request.PostLogoutRedirectUris.Contains(p.PostLogoutRedirectUri));
            foreach (var postLogoutRedirectUri in request.PostLogoutRedirectUris.Distinct())
            {
                if (!client.PostLogoutRedirectUris.Any(p => p.PostLogoutRedirectUri == postLogoutRedirectUri))
                {
                    client.PostLogoutRedirectUris.Add(new ID4_EF_E.ClientPostLogoutRedirectUri {
                        PostLogoutRedirectUri = postLogoutRedirectUri
                    });
                }
            }

            client.Properties.RemoveAll(cp => !request.Properties.Any(rp => rp.Key == cp.Key && rp.Value == cp.Value));
            foreach (var property in request.Properties.Distinct())
            {
                var currentProperty = client.Properties.FirstOrDefault(p => p.Key == property.Key);
                if (currentProperty != null)
                {
                    currentProperty.Value = property.Value;
                }
                else
                {
                    client.Properties.Add(new ID4_EF_E.ClientProperty {
                        Key = property.Key, Value = property.Value
                    });
                }
            }

            client.RedirectUris.RemoveAll(p => !request.RedirectUris.Contains(p.RedirectUri));
            foreach (var redirectUri in request.RedirectUris.Distinct())
            {
                if (!client.RedirectUris.Any(p => p.RedirectUri == redirectUri))
                {
                    client.RedirectUris.Add(new ID4_EF_E.ClientRedirectUri {
                        RedirectUri = redirectUri
                    });
                }
            }

            await _configurationRepository.BulkSaveChangesAsync(cancellationToken);

            return(Unit.Value);
        }
Esempio n. 25
0
 public List <SoortAfspraak> GetMassages()
 {
     return(repoMassage.All().ToList <SoortAfspraak>());
 }
Esempio n. 26
0
 public List <Arrangement> GetArrangementen()
 {
     return(repoArrangement.All().ToList <Arrangement>());
 }
Esempio n. 27
0
 public List <Extra> GetExtras()
 {
     return(repoExtra.All().ToList <Extra>());
 }
Esempio n. 28
0
 public List <Country> GetAll()
 {
     return(_countryRepo.All().ToList());
 }
        public async Task <Unit> Handle(UpdateApiResourceCommand request, CancellationToken cancellationToken)
        {
            var apiResource = await _configurationRepository
                              .All <IdentityServer4.EntityFramework.Entities.ApiResource>()
                              .SingleAsync(r => r.Id == request.Id);

            apiResource.Name        = request.Name;
            apiResource.DisplayName = request.DisplayName;
            apiResource.Description = request.Description;
            apiResource.Enabled     = request.Enabled;

            apiResource.Secrets.RemoveAll(s => !request.ApiSecrets.Select(rs => rs.Value.Sha256()).Contains(s.Value));
            foreach (var apiSecret in request.ApiSecrets.DistinctBy(s => s.Value))
            {
                var shaSecret = apiSecret.Value.Sha256();

                var secret = apiResource.Secrets.FirstOrDefault(s => s.Value == shaSecret);
                if (secret != null)
                {
                    secret.Type        = apiSecret.Type;
                    secret.Value       = shaSecret;
                    secret.Description = apiSecret.Description;
                    secret.Expiration  = apiSecret.Expiration;
                }
                else
                {
                    apiResource.Secrets.Add(new IdentityServer4.EntityFramework.Entities.ApiSecret
                    {
                        Type        = apiSecret.Type,
                        Value       = shaSecret,
                        Description = apiSecret.Description,
                        Created     = DateTime.UtcNow,
                        Expiration  = apiSecret.Expiration
                    });
                }
            }

            apiResource.Scopes.RemoveAll(s => !request.Scopes.Any(rs => rs.Name == s.Name));
            foreach (var apiScope in request.Scopes.Distinct())
            {
                if (!apiResource.Scopes.Any(s => s.Name == apiScope.Name))
                {
                    apiResource.Scopes.Add(new IdentityServer4.EntityFramework.Entities.ApiScope
                    {
                        Name                    = apiScope.Name,
                        DisplayName             = apiScope.DisplayName,
                        Description             = apiScope.Description,
                        Emphasize               = apiScope.Emphasize,
                        Required                = apiScope.Required,
                        ShowInDiscoveryDocument = apiScope.ShowInDiscoveryDocument
                    });
                }
            }

            apiResource.UserClaims.RemoveAll(ac => !request.UserClaims.Any(rc => rc == ac.Type));
            foreach (var claimType in request.UserClaims.Distinct())
            {
                if (!apiResource.UserClaims.Any(c => c.Type == claimType))
                {
                    apiResource.UserClaims.Add(new IdentityServer4.EntityFramework.Entities.ApiResourceClaim
                    {
                        Type = claimType
                    });
                }
            }

            apiResource.Properties.RemoveAll(ap => !request.Properties.Any(rp => rp.Key == ap.Key && rp.Value == ap.Value));
            foreach (var property in request.Properties.Distinct())
            {
                var currentProperty = apiResource.Properties.FirstOrDefault(p => p.Key == property.Key);
                if (currentProperty != null)
                {
                    currentProperty.Value = property.Value;
                }
                else
                {
                    apiResource.Properties.Add(new IdentityServer4.EntityFramework.Entities.ApiResourceProperty
                    {
                        Key   = property.Key,
                        Value = property.Value
                    });
                }
            }

            await _configurationRepository.SaveChangesAsync();

            return(Unit.Value);
        }
Esempio n. 30
0
 public virtual IQueryable <T> All()
 {
     return(Repository.All());
 }
Esempio n. 31
0
        public IActionResult Index()
        {
            var model = _userRepository.All();

            return(View(model));
        }