コード例 #1
0
        public IActionResult OnGet(string link)
        {
            if (link == null)
            {
                return(NotFound());
            }

            var resultLink = _repository.Single(LinkSpecification.ByUrl(link));

            if (resultLink == null)
            {
                return(NotFound());
            }

            var resultTopic = _repository.SingleInclude(BaseSpecification <Topic> .ById(resultLink.TopicId), new List <ISpecification <Topic> > {
                TopicSpecification.IncludeQuestions()
            });

            if (resultTopic == null)
            {
                return(NotFound());
            }

            Questions = resultTopic.Questions;
            Link      = link;
            Title     = resultTopic.Title;

            return(Page());
        }
コード例 #2
0
        private Result RoleIsValid(string roleId)
        {
            if (roleId == null)
            {
                _logger.LogInformation($"Adding GroupUser without role");
                return(Result.Ok());
            }

            BaseSpecification <RoleEntity> baseSpecification = new BaseSpecification <RoleEntity>();

            baseSpecification.AddFilter(x => x.Id == roleId);
            baseSpecification.AddFilter(x => x.Type == Data.Enums.Entity.RoleTypes.Group);

            RoleEntity role = _roleRepository.SingleOrDefault(baseSpecification);

            if (role == null)
            {
                _logger.LogError($"No GroupRole. RoleId {roleId}");
                return(Result.Fail("no_group_role", "No GroupRole"));
            }

            List <RoleListData> canAssigneRoles = _groupUserStore.CanAssigneGroupRoles();

            if (!canAssigneRoles.Any(x => x.Id == roleId))
            {
                _logger.LogError($"User can not assign that GroupRole. GroupRoleId {roleId}");
                return(Result.Fail("no_permission", "No permission"));
            }

            return(Result.Ok());
        }
コード例 #3
0
        public IActionResult OnGet(string link)
        {
            if (link == null)
            {
                return(NotFound());
            }

            var resultLink = _repository.Single(LinkSpecification.ByUrl(link));

            if (resultLink == null)
            {
                return(NotFound());
            }

            var resultTopic = _repository.Single(BaseSpecification <Topic> .ById(resultLink.TopicId));

            if (resultTopic == null)
            {
                return(NotFound());
            }

            if (resultTopic.PreventSpam)
            {
                ShowReCaptcha = true;
            }

            Title        = resultTopic.Title;
            ShortcutLink = link;
            return(Page());
        }
コード例 #4
0
        private async Task <List <ErrorsTO> > ValidateLinkedProcessId(ProcessRequestTO processRequestTO)
        {
            var errors = new List <ErrorsTO>();

            var processSpecification = new BaseSpecification <ProcessEntity>();

            processSpecification.AddCriteria(process => process.Id == processRequestTO.LinkedProcessId);
            var processFather = (await _processRepository.ListAsync(processSpecification)).FirstOrDefault();

            var cont = 0;

            while (processFather != null && processFather.LinkedProcessId != null)
            {
                cont++;
                processSpecification = new BaseSpecification <ProcessEntity>();
                processSpecification.AddCriteria(process => process.Id == processRequestTO.LinkedProcessId);
                processFather = (await _processRepository.ListAsync(processSpecification)).FirstOrDefault();
            }

            if (cont > 4)
            {
                errors.Add(new ErrorsTO
                {
                    Field      = "LinkedProcessId",
                    Validation = Messaging.ExceededLimitOfHierarchyLinkedProcessId
                });
            }

            return(errors);
        }
コード例 #5
0
        public async Task <Result> Update(string userId, long attributeId, UpdateUserAttributeModel updateUserAttribute)
        {
            ValidationResult validationResult = _updateUserAttribute.Validate(updateUserAttribute);

            if (!validationResult.IsValid)
            {
                _logger.LogWarning($"Invalid {typeof(UpdateUserAttributeModel).CustomAttributes} model");
                return(Result.Fail(validationResult.Errors));
            }

            BaseSpecification <UserAttributeEntity> baseSpecification = new BaseSpecification <UserAttributeEntity>();

            baseSpecification.AddFilter(x => x.Id == attributeId);
            baseSpecification.AddFilter(x => x.UserId == userId);

            UserAttributeEntity userAttribute = await _userAttributeRepository.SingleOrDefault(baseSpecification);

            if (userAttribute == null)
            {
                _logger.LogError($"No UserAttribute. UserId {userId}, AttributeId {attributeId}");
                return(Result.Fail("no_user_attribute", "No UserAttribute"));
            }

            userAttribute.Value = updateUserAttribute.Value;

            bool updateResult = await _userAttributeRepository.Update(userAttribute);

            if (!updateResult)
            {
                _logger.LogError($"Failed to update UserAttribute. UserId {userId}, AttributeId {attributeId}");
                return(Result.Fail("failed_to_update_user_attribute", "Failed to update user attribute"));
            }

            return(Result.Ok());
        }
コード例 #6
0
        public async Task <Result> Remove(string userId, long attributeId)
        {
            BaseSpecification <UserAttributeEntity> baseSpecification = new BaseSpecification <UserAttributeEntity>();

            baseSpecification.AddFilter(x => x.Id == attributeId);
            baseSpecification.AddFilter(x => x.UserId == userId);

            UserAttributeEntity userAttribute = await _userAttributeRepository.SingleOrDefault(baseSpecification);

            if (userAttribute == null)
            {
                _logger.LogError($"No UserAttribute. UserId {userId}, AttributeId {attributeId}");
                return(Result.Fail("no_user_attribute", "No UserAttribute"));
            }

            bool removeResult = await _userAttributeRepository.Remove(userAttribute);

            if (!removeResult)
            {
                _logger.LogError($"Failed to remove user attribute. UserId {userId}, AttributeId {attributeId}");
                return(Result.Fail("failed_to_remove_user_attribute", "Failed to remove user attribute"));
            }

            return(Result.Ok());
        }
コード例 #7
0
        public async Task <List <MessageViewModel> > GetMessages(Guid senderId, Guid receiverId, int pageIndex)
        {
            Group group = await _groupRepository.GetByIdAsync(receiverId);

            BaseSpecification <Message> messageSpec;

            if (group != null)
            {
                messageSpec = new BaseSpecification <Message>();
                messageSpec.AddCriteria(x => x.ToGroupId == receiverId);
            }
            else
            {
                messageSpec = new BaseSpecification <Message>();
                messageSpec.AddCriteria(x => x.FromUserId == senderId && x.ToUserId == receiverId || x.FromUserId == receiverId && x.ToUserId == senderId);
            }

            messageSpec.ApplyPaging(pageIndex * Constants.ItemsPerPage, Constants.ItemsPerPage);
            messageSpec.ApplyOrderByDescending(x => x.Created);
            messageSpec.AddInclude(x => x.FromUser);
            IReadOnlyList <Message> messagesOnPage = await _messageRepository.ListAsync(messageSpec);

            ChatViewModel result = new ChatViewModel();

            return(messagesOnPage.Select(x => ConvertTo(x, senderId, receiverId)).ToList());
        }
コード例 #8
0
        public Result Add(AddGroupRequest addGroup)
        {
            ValidationResult validationResult = _addGroupValidator.Validate(addGroup);

            if (!validationResult.IsValid)
            {
                _logger.LogWarning($"Invalid AddGroupRequest model");
                return(Result.Fail(validationResult.Errors));
            }

            BaseSpecification <GroupEntity> groupExistSpecification = new BaseSpecification <GroupEntity>();

            groupExistSpecification.AddFilter(x => x.Name.ToUpper() == addGroup.Name.ToUpper());

            bool groupExist = _groupRepository.Exist(groupExistSpecification);

            if (groupExist)
            {
                _logger.LogError($"Group with the same name already exist");
                return(Result.Fail("group_with_name_already_exist", "Group with name already exist"));
            }

            GroupEntity group = new GroupEntity(
                name: addGroup.Name);

            bool addResult = _groupRepository.Add(group);

            if (!addResult)
            {
                _logger.LogError($"Failed to add group");
                return(Result.Fail("failed_to_add_group", "Failed to add group"));
            }

            return(Result.Ok());
        }
コード例 #9
0
        public Result <RoleViewModel> GetRoles(string id)
        {
            BaseSpecification <AppUserEntity> userSpecification = new BaseSpecification <AppUserEntity>();

            userSpecification.AddFilter(x => x.Id == id);

            bool existResult = _userRepository.Exist(userSpecification);

            if (!existResult)
            {
                _logger.LogWarning($"No user. UserId {id}");
                return(Result.Fail <RoleViewModel>("no_user", "No user"));
            }

            List <RoleEntity> assignedRoles = _roleRepository.GetAssigned(id);
            List <RoleEntity> avaibleRoles  = _roleRepository.GetAvailable(id);

            RoleViewModel roleViewModel = new RoleViewModel(
                assignedRoles: assignedRoles
                .Select(x => new RoleViewModel.RoleModel(x.Id, x.Name))
                .OrderBy(x => x.Name)
                .ToList(),
                availableRoles: avaibleRoles
                .Select(x => new RoleViewModel.RoleModel(x.Id, x.Name))
                .OrderBy(x => x.Name)
                .ToList());

            return(Result.Ok(roleViewModel));
        }
コード例 #10
0
        public Result Remove(string id)
        {
            BaseSpecification <PermissionEntity> baseSpecification = new BaseSpecification <PermissionEntity>();

            baseSpecification.AddFilter(x => x.Id == id);

            PermissionEntity permission = _permissionRepository.SingleOrDefault(baseSpecification);

            if (permission == null)
            {
                _logger.LogError($"No permission. PermissionId {id}");
                return(Result.Fail("no_permission", "No Permission"));
            }

            _logger.LogInformation($"Removing permission. PermissionId {id}, Name {permission.Name}");

            bool updateResult = _permissionRepository.Remove(permission);

            if (!updateResult)
            {
                _logger.LogError($"Failed to remove permission. PermissionId {id}");
                return(Result.Fail("failed_to_remove_permission", "Failed to remove permission"));
            }

            return(Result.Ok());
        }
コード例 #11
0
        public async Task <Result <string> > GetProfileImageURL(string userId)
        {
            string cacheKey = string.Format(URL_CACHE_KEY, userId);

            if (_memoryCache.TryGetValue(cacheKey, out string imageUrl))
            {
                return(Result.Ok(imageUrl));
            }

            BaseSpecification <UserImageEntity> userImageSpecification = new BaseSpecification <UserImageEntity>();

            userImageSpecification.AddFilter(x => x.UserId == userId);

            UserImageEntity userImage = await _userImageRepository.SingleOrDefault(userImageSpecification);

            if (userImage == null)
            {
                _logger.LogError($"No profile image. UserId {userId}");

                return(Result.Fail <string>("no_profile_image", "No Profile image"));
            }

            _memoryCache.Set(cacheKey, userImage.URL, IMAGE_IN_CACHE_TIME_SPAN);

            return(Result.Ok(userImage.URL));
        }
コード例 #12
0
        private async Task <Result> AddToGlobalRole(AppUserEntity appUser, string roleId)
        {
            _logger.LogInformation($"Adding user to global role. UserId {appUser.Id}, RoleId {roleId}");

            BaseSpecification <RoleEntity> baseSpecification = new BaseSpecification <RoleEntity>();

            baseSpecification.AddFilter(x => x.Id == roleId);
            baseSpecification.AddFilter(x => x.Type == Data.Enums.Entity.RoleTypes.Global);

            RoleEntity role = _roleRepository.SingleOrDefault(baseSpecification);

            if (role == null)
            {
                _logger.LogError($"No GlobalRole. RoleId {roleId}");
                return(Result.Fail("no_role", "No Role"));
            }

            IdentityResult addResult = await _userManager.AddToRoleAsync(appUser, role.Name);

            if (!addResult.Succeeded)
            {
                _logger.LogError($"Failed to add role. UserId {appUser.Id}, RoleId {roleId}");
                return(Result.Fail("failed_to_add_role", "Failed to add role"));
            }

            return(Result.Ok());
        }
コード例 #13
0
        public async Task <Operation> GetByIdWithGraphAsync(int id)
        {
            BaseSpecification <Operation> spec = new BaseSpecification <Operation>(O => O.Id == id);

            spec.AddInclude(o => o.IdCategorieNavigation);
            return(await _repositoryAsync.GetSingleBySpecAsync(spec));
        }
コード例 #14
0
        public Result UnlockUser(UnlockUserRequest request, string adminId)
        {
            ValidationResult validationResult = _unlockUserValidator.Validate(request);

            if (!validationResult.IsValid)
            {
                _logger.LogWarning($"Invlid UnlockUserRequest. AdminId {adminId}");
                return(Result.Fail(validationResult.Errors));
            }

            BaseSpecification <AppUserEntity> userSpecification = new BaseSpecification <AppUserEntity>();

            userSpecification.AddFilter(x => x.Id == request.UserId);

            AppUserEntity appUser = _userRepository.SingleOrDefault(userSpecification);

            if (appUser == null)
            {
                _logger.LogWarning($"No User. UserId {request.UserId}, AdminId {adminId}");
                return(Result.Fail("no_user", "No user"));
            }

            appUser.AccessFailedCount = 0;
            appUser.LockoutEnd        = null;

            bool result = _userRepository.Update(appUser);

            if (!result)
            {
                _logger.LogError($"Faild to unlock user. AdminId {adminId}");
                return(Result.Fail("error", "Error"));
            }

            return(Result.Ok());
        }
コード例 #15
0
        public Result Remove(string id)
        {
            _logger.LogInformation($"Removing Invite. InviteId {id}");

            BaseSpecification <InviteEntity> baseSpecification = new BaseSpecification <InviteEntity>();

            baseSpecification.AddFilter(x => x.Id == id);

            InviteEntity invite = _inviteRepository.SingleOrDefault(baseSpecification);

            if (invite == null)
            {
                _logger.LogError($"No Invite. InviteId {id}");
                return(Result.Fail("no_invite", "No Invite"));
            }

            bool removeResult = _inviteRepository.Remove(invite);

            if (!removeResult)
            {
                _logger.LogError($"Failed to remove invite. InviteId {id}");
                return(Result.Fail("failed_to_remove_invite", "Failed to remove invite"));
            }

            return(Result.Ok());
        }
コード例 #16
0
        public Result Remove(string id)
        {
            BaseSpecification <RoleEntity> roleSpecification = new BaseSpecification <RoleEntity>();

            roleSpecification.AddFilter(x => x.Id == id);

            RoleEntity role = _roleRepository.SingleOrDefault(roleSpecification);

            if (role == null)
            {
                _logger.LogError($"No role");
                return(Result.Fail("no_role", "No Role"));
            }

            _logger.LogInformation($"Removing Role. RoleId {id}, Name {role.Name}");

            bool removeResult = _roleRepository.Remove(role);

            if (!removeResult)
            {
                _logger.LogError($"Failed to remove Role. RoleId {id}, Name {role.Name}");
                return(Result.Fail("failed_to_remove_role", "Failed to remove role"));
            }

            return(Result.Ok());
        }
コード例 #17
0
        public Result EditRole(string id, EditRoleRequest editRoleRequest, string adminId)
        {
            ValidationResult validationResult = _editRoleValidator.Validate(editRoleRequest);

            if (!validationResult.IsValid)
            {
                _logger.LogError($"Invalid EditRoleRequest. admin {adminId}");
                return(Result.Fail(ResultUtils.ToResultError(validationResult.Errors)));
            }

            BaseSpecification <RoleEntity> roleSpecification = new BaseSpecification <RoleEntity>();

            roleSpecification.AddFilter(x => x.Id == id);

            RoleEntity role = _roleRepository.SingleOrDefault(roleSpecification);

            if (role == null)
            {
                _logger.LogError($"No role. Admin id {adminId}");
                return(Result.Fail("no_role", "No Role"));
            }

            role.Description = editRoleRequest.Description;

            bool result = _roleRepository.Update(role);

            if (!result)
            {
                _logger.LogError($"Failed to update role with id {id}. Admin {adminId}");
                return(Result.Fail("error", "Error"));
            }

            return(Result.Ok());
        }
コード例 #18
0
        private Result RemoveGroupRole(string userId, string roleId)
        {
            BaseSpecification <GroupUserEntity> baseSpecification = new BaseSpecification <GroupUserEntity>();

            baseSpecification.AddFilter(x => x.UserId == userId);
            baseSpecification.AddFilter(x => x.RoleId == roleId);

            GroupUserEntity groupUser = _groupUserRepository.SingleOrDefault(baseSpecification);

            if (groupUser == null)
            {
                _logger.LogError($"No GroupUser. UserId {userId}, roleId {roleId}");
                return(Result.Fail("no_group_user", "No GroupUser"));
            }

            groupUser.UpdateRole(null);

            bool updateResult = _groupUserRepository.Update(groupUser);

            if (!updateResult)
            {
                _logger.LogError($"Failed to update GroupUser. UserId {userId}, roleId {roleId}");
                return(Result.Fail("failed_to_update_group_user", "Failed to update GroupUser"));
            }

            return(Result.Ok());
        }
コード例 #19
0
        public async Task <Result> SendEmilVerificationMail(SendEmailVerificationMailRequest request, string adminId)
        {
            ValidationResult validationResult = _sendEmailVerificationMailValidator.Validate(request);

            if (!validationResult.IsValid)
            {
                _logger.LogWarning($"Invlid SendEmailVerificationMailRequest. AdminId {adminId}");
                return(Result.Fail(validationResult.Errors));
            }

            BaseSpecification <AppUserEntity> userSpecification = new BaseSpecification <AppUserEntity>();

            userSpecification.AddFilter(x => x.Id == request.UserId);

            AppUserEntity appUser = _userRepository.SingleOrDefault(userSpecification);

            if (appUser == null)
            {
                _logger.LogWarning($"No User. UserId {request.UserId}, AdminId {adminId}");
                return(Result.Fail("no_user", "No user"));
            }

            string code = await _userManager.GenerateEmailConfirmationTokenAsync(appUser);

            await _emailConfirmationService.SendVerificationMail(appUser, code);

            return(Result.Ok());
        }
コード例 #20
0
        public async Task <Result> RemoveRole(string userId, string roleId)
        {
            BaseSpecification <RoleEntity> getRoleSpecification = new BaseSpecification <RoleEntity>();

            getRoleSpecification.AddFilter(x => x.Id == roleId);

            RoleEntity role = _roleRepository.SingleOrDefault(getRoleSpecification);

            if (role == null)
            {
                _logger.LogError($"No role. RoleId {roleId}");
                return(Result.Fail("no_role", "No Role"));
            }

            switch (role.Type)
            {
            case Data.Enums.Entity.RoleTypes.Global:
            {
                return(await RemoveGlobalRole(userId, role.Name));
            }

            case Data.Enums.Entity.RoleTypes.Group:
            {
                return(RemoveGroupRole(userId, roleId));
            }

            default:
            {
                _logger.LogError($"Invalid Role type. RoleId {roleId}");
                return(Result.Fail("invalid_role_type", "Invalid role type"));
            }
            }
        }
コード例 #21
0
        public async Task <IDataSourceResult <ActivityLog> > GetActivityLogsAsync(
            int skip,
            int take,
            string ipAddress = "",
            string message   = "",
            string userId    = null,
            ActivityTypeEnum?activityType = null,
            DateTime?startCreatedTime     = null,
            DateTime?endCreatedTime       = null)
        {
            BaseSpecification <ActivityLog> activityLogSpecification = new BaseSpecification <ActivityLog>(q =>
                                                                                                           (string.IsNullOrEmpty(message) || EF.Functions.Contains(q.Message, message)) &&
                                                                                                           (string.IsNullOrEmpty(userId) || q.UserId == userId) &&
                                                                                                           (string.IsNullOrEmpty(ipAddress) || q.IpAddress == ipAddress) &&
                                                                                                           (!startCreatedTime.HasValue || q.CreatedTime >= startCreatedTime) &&
                                                                                                           (!endCreatedTime.HasValue || q.CreatedTime <= endCreatedTime) &&
                                                                                                           (!activityType.HasValue || q.Type == activityType));

            activityLogSpecification.ApplyOrderByDescending(q => q.Id);
            activityLogSpecification.ApplySelector(q => new ActivityLog
            {
                Id          = q.Id,
                CreatedTime = q.CreatedTime,
                UserId      = q.UserId,
                Message     = q.Message,
                Type        = q.Type,
                ObjectType  = q.ObjectType,
                IpAddress   = q.IpAddress,
                Complete    = q.Complete
            });
            activityLogSpecification.ApplyPaging(skip, take);
            return(await ToDataSourceResultAsync(activityLogSpecification));
        }
コード例 #22
0
        public Core.Models.Result.Result Logout(string sessionCode, string userId, SessionEndTypes endType)
        {
            BaseSpecification <SessionEntity> specification = new BaseSpecification <SessionEntity>();

            specification.AddFilter(x => x.Code == sessionCode);
            specification.AddFilter(x => x.UserId == userId);

            SessionEntity session = _sessionRepository.SingleOrDefault(specification);

            if (session == null)
            {
                _logger.LogError($"Sesion does not exist. SessionCode {sessionCode}, userId {userId}");
                return(Core.Models.Result.Result.Fail("no_session", "No Session"));
            }

            session.EndType = endType;

            bool removeSessionResult = _sessionRepository.Remove(session);

            if (!removeSessionResult)
            {
                _logger.LogError($"Faild to remove session. SessionCode {sessionCode}, userId {userId}");
                return(Core.Models.Result.Result.Fail("error", "Error"));
            }

            _logger.LogInformation($"User session logout. UserId {userId}");

            return(Core.Models.Result.Result.Ok());
        }
コード例 #23
0
        public Result Edit(string id, EditPermissionRequest editPermission)
        {
            BaseSpecification <PermissionEntity> baseSpecification = new BaseSpecification <PermissionEntity>();

            baseSpecification.AddFilter(x => x.Id == id);

            PermissionEntity permission = _permissionRepository.SingleOrDefault(baseSpecification);

            if (permission == null)
            {
                _logger.LogError($"No permission. PermissionId {id}");
                return(Result.Fail("no_permission", "No Permission"));
            }

            permission.Update(editPermission.Description);

            bool updateResult = _permissionRepository.Update(permission);

            if (!updateResult)
            {
                _logger.LogError($"Failed to update permission. PermissionId {id}");
                return(Result.Fail("failed_to_update_permission", "Failed to update permission"));
            }

            return(Result.Ok());
        }
コード例 #24
0
        public Result Add(string roleId, AddRoleAssignmentRequest addRoleAssignment)
        {
            ValidationResult validationResult = _addRoleAssignmentValidator.Validate(addRoleAssignment);

            if (!validationResult.IsValid)
            {
                _logger.LogWarning($"Invalid AddRoleAssignmentRequest model");
                return(Result.Fail(validationResult.Errors));
            }

            if (roleId == addRoleAssignment.RoleId)
            {
                _logger.LogError($"Can not assign Role to itself. RoleId {roleId}");
                return(Result.Fail("can_not_assigne_to_itself", "Can not assign Role to itself"));
            }

            Result roleExist = ValidateRole(roleId);

            if (roleExist.Failure)
            {
                return(Result.Fail(roleExist.Errors));
            }

            Result canAssigneRoleExist = ValidateRole(addRoleAssignment.RoleId);

            if (canAssigneRoleExist.Failure)
            {
                return(Result.Fail(canAssigneRoleExist.Errors));
            }

            BaseSpecification <RoleAssignmentEntity> roleAlreadyAssignedSpecification = new BaseSpecification <RoleAssignmentEntity>();

            roleAlreadyAssignedSpecification.AddFilter(x => x.RoleId == roleId);
            roleAlreadyAssignedSpecification.AddFilter(x => x.CanAssigneRoleId == addRoleAssignment.RoleId);

            bool roleAlreadyAssigned = _groupRoleAssignmentRepository.Exist(roleAlreadyAssignedSpecification);

            if (roleAlreadyAssigned)
            {
                _logger.LogError($"Role is already assigned. RoleId {roleId}, CanAssigneRoleId {addRoleAssignment.RoleId}");
                return(Result.Fail("role_is_already_assigned", "Role is already assigned"));
            }

            //TODO: check for recursion loop if we are going to use role assignment recursion

            RoleAssignmentEntity roleAssignment = new RoleAssignmentEntity(
                roleId: roleId,
                canAssigneRoleId: addRoleAssignment.RoleId);

            bool addResult = _groupRoleAssignmentRepository.Add(roleAssignment);

            if (!addResult)
            {
                _logger.LogError($"Failed to add GroupRoleAssignment, RoleId {roleId}, CanAssignedRoleId {addRoleAssignment.RoleId}");
                return(Result.Fail("failed_to_add_role_assignment", "Failed to add RoleAssignment"));
            }

            return(Result.Ok());
        }
コード例 #25
0
        public async Task <IReadOnlyList <Operation> > ListAllWithGraphAsync()
        {
            BaseSpecification <Operation> spec = new BaseSpecification <Operation>();

            spec.AddInclude(o => o.IdCategorieNavigation);
            spec.ApplyOrderBy(O => O.Dateoperation);
            return(await this.ListAsync(spec));
        }
コード例 #26
0
        public static BaseSpecification <TodoItem> NameStartWith(string name, int skip, int take)
        {
            var spec = new BaseSpecification <TodoItem>(t => t.Name.Contains(name));

            spec.ApplyOrderBy(t => t.Name);
            spec.ApplyPaging(skip, take);
            return(spec);
        }
コード例 #27
0
        public Core.Models.Result.Result <GroupUserEntity> Get(long id)
        {
            BaseSpecification <GroupUserEntity> getGroupUserSpecification = new BaseSpecification <GroupUserEntity>();

            getGroupUserSpecification.AddFilter(x => x.Id == id);

            return(Get(getGroupUserSpecification));
        }
コード例 #28
0
        public async Task <ActionResult <IReadOnlyList <ProductType> > > GetTypes()
        {
            var spec = new BaseSpecification <ProductType>();

            var result = await typeRepo.GetListWithSpec(spec);

            return(Ok(result));
        }
コード例 #29
0
        public Core.Models.Result.Result Exists(long id)
        {
            BaseSpecification <GroupUserEntity> baseSpecification = new BaseSpecification <GroupUserEntity>();

            baseSpecification.AddFilter(x => x.Id == id);

            return(Exists(baseSpecification));
        }
コード例 #30
0
        private IEnumerable <SelectListItem> FirstPlayers(string nameCurrentUser)
        {
            BaseSpecification <Profile> query = IsAdmin() ? (BaseSpecification <Profile>) new AllProfiles() : new SpecificProfile(nameCurrentUser);

            return(_gamesService.List(query)
                   .OrderBy(profile => profile.DisplayName)
                   .Select(profile => new SelectListItem(profile.DisplayName, profile.EmailAddress)));
        }
コード例 #31
0
ファイル: SpecTestBase.cs プロジェクト: joaomajesus/Tarantino
		public void SetUp()
		{
			_trueSpec = new GenericSpecification(x => true);
			_falseSpec = new GenericSpecification(x => false);
		}