Esempio n. 1
0
        private async Task AssignFunctionsToRoleFromFunctionIdList(RoleModel role, List <Guid> functionIds)
        {
            // The user associations for this role are going to be created or overwritten, its easier to rebuild it that apply a diff.
            role.RoleFunctions = new List <RoleFunctionModel>();

            if (functionIds != null && functionIds.Count > 0)
            {
                foreach (var functionId in functionIds)
                {
                    var function = await functionRepository.GetByIdAsync(functionId);

                    if (function == null)
                    {
                        logger.Warn("Unable to find a function with ID: " + function + "when attempting to assign the function to a role.");
                        break;
                    }

                    role.RoleFunctions.Add(new RoleFunctionModel
                    {
                        Role     = role,
                        Function = function
                    });
                }
            }
        }
Esempio n. 2
0
 public async Task <Function> GetByIdAsync(Guid functionId)
 {
     return(mapper.Map <Function>(await functionRepository.GetByIdAsync(functionId)));
 }