public static bool CanChangeRoleOfMember(this AppUserRole caller, AppUserRole oldRole, AppUserRole newRole)
        {
            if (caller.IsNone() || oldRole.IsNone() || newRole.IsNone())
            {
                return(false);
            }
            if (!HasPermissionsToChangeRoleOfMember(caller))
            {
                return(false);
            }
            if (oldRole == newRole)
            {
                return(false);
            }
            if (oldRole.IsOwner() || newRole.IsOwner())
            {
                return(false);
            }
            if ((oldRole.IsScrumMaster() || newRole.IsScrumMaster()) && !caller.IsOwner())
            {
                return(false);
            }

            return(true);
        }
 /// <summary>
 /// Defines user roles which can change project state.
 /// </summary>
 /// <param name="projectBl">Extends project business logic class.</param>
 /// <param name="role">Role of user in project.</param>
 /// <returns>Boolean value which points to possibility to change project state.</returns>
 public static bool CanChangeProject(this ProjectBl projectBl, AppUserRole role)
 {
     if (role.IsOwner())
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
 public static bool CanAddNewMember(this AppUserRole role)
 {
     if (role.IsOwner())
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
 public static bool HasPermissionsToChangeRoleOfMember(this AppUserRole role)
 {
     if (role.IsOwner() || role.IsScrumMaster())
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
 public static bool CanRemoveItself(this AppUserRole role)
 {
     if (role.IsOwner() || role.IsNone())
     {
         return(false);
     }
     else
     {
         return(true);
     }
 }
Esempio n. 6
0
 /// <summary>
 /// Defines user roles which can change sprint state.
 /// </summary>
 /// <param name="sprintBl">Extends sprint business logic class.</param>
 /// <param name="role">Role of user in project.</param>
 /// <returns>Boolean value which points to possibility to change sprint state.</returns>
 public static bool CanChangeSprint(this SprintBl sprintBl, AppUserRole role)
 {
     if (role.IsScrumMaster() || role.IsOwner())
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
 public static bool IsPartOfTeam(this AppUserRole role)
 {
     if (role.IsOwner() || role.IsScrumMaster() || role.IsDeveloper())
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
 public static bool IsScrumMasterOrOwner(this AppUserRole role)
 {
     if (role.IsOwner() || role.IsScrumMaster())
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
 /// <summary>
 /// Defines user roles which can view project data.
 /// </summary>
 /// <param name="projectBl">Extends project business logic class.</param>
 /// <param name="role">Role of user in project.</param>
 /// <returns>Boolean value which points to possibility to view project data.</returns>
 public static bool CanAccessProject(this ProjectBl projectBl, AppUserRole role)
 {
     if (role.IsScrumMaster() || role.IsOwner() ||
         role.IsDeveloper() || role.IsObserver())
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
Esempio n. 10
0
        public async Task AddMemberAsync(string senderUserId, int projectId, string userId, AppUserRoleDto roleDto)
        {
            AppUserRole senderRole = await GetRoleIfMember(senderUserId, projectId);

            if (!senderRole.CanAddNewMember())
            {
                throw new ForbiddenResponseException("You haven't permissions to add members to this project");
            }

            if (!await _userRepo.ExistsWithId(userId))
            {
                throw new NotFoundResponseException("Cannot find user to add into project.");
            }

            if (!((await _puRepo.GetRoleOfMember(userId, projectId)).IsNone()))
            {
                throw new BadRequestResponseException("This user already exists in project.");
            }

            AppUserRole role = _mapper.Map <AppUserRoleDto, AppUserRole>(roleDto);

            if (role.IsNone())
            {
                throw new BadRequestResponseException("Given role is bad.");
            }

            if (role.IsOwner())
            {
                throw new BadRequestResponseException("Cannot add Owner to project.");
            }

            if (role.IsScrumMaster() && await _puRepo.DoesExistScrumMasterInProjectAsync(projectId))
            {
                throw new BadRequestResponseException("Scrum Master already exists in project.");
            }

            var pu = new ProjectUser()
            {
                ProjectId  = projectId,
                UserId     = userId,
                UserRoleId = role.Id
            };
            await _puRepo.CreateRecordAsync(pu);
        }
 public static bool CanSetAssignedUser(this AppUserRole role)
 {
     return(role.IsOwner() || role.IsScrumMaster());
 }