Ejemplo n.º 1
0
        /// <summary>
        /// Get Users For Examination
        /// </summary>
        /// <param name="examination">Examination.</param>
        /// <param name="role">Role.</param>
        /// <returns>List of Users.</returns>
        private async Task <IEnumerable <MeUser> > GetUsersForExamination(Examination examination, UserRoles role)
        {
            var locations = examination.LocationIds();

            var users = await _usersRetrievalByRoleLocationQueryService.Handle(new UsersRetrievalByRoleLocationQuery(locations, new[] { role }));

            return(users);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Has Role for Examination.
        /// </summary>
        /// <param name="user">The User.</param>
        /// <param name="examination">The Examination.</param>
        /// <param name="role">The Role required.</param>
        /// <returns>True if user has role.</returns>
        public static bool HasRoleForExamination(
            this MedicalExaminer.Models.MeUser user,
            Examination examination,
            UserRoles role)
        {
            var locations = examination.LocationIds();

            var permissions = user.Permissions.Where(p => locations.Contains(p.LocationId)).ToList();

            return(permissions.Any(p => p.UserRole == role));
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Role For Examination.
        /// </summary>
        /// <param name="user">The user.</param>
        /// <param name="examination">The examination.</param>
        /// <returns>The highest role they have for this examination.</returns>
        public static UserRoles?RoleForExamination(this MedicalExaminer.Models.MeUser user, Examination examination)
        {
            var locations = examination.LocationIds();

            var permissions = user.Permissions.Where(p => locations.Contains(p.LocationId)).ToList();

            if (permissions.Any())
            {
                var topPermission = permissions.OrderByDescending(p => p.UserRole).First();

                return(topPermission.UserRole);
            }

            return(null);
        }