Beispiel #1
0
        /// <summary>
        /// Role creation method
        /// </summary>
        /// <param name = "data"> Data </param>
        /// <returns> </returns>
        public RoleVm Create(RoleSubmitM data)
        {
            if (_context.Roles.Any(r => r.Name == data.Name))
            {
                throw new Exception(nameof(Resource.NameError));
            }

            var role = new Role
            {
                Name        = data.Name,
                Description = data.Description,
                AccessToSystemFunctionsArray = data.AccessToSystemFunctions,
                StandardDataAccessArray      = data.StandardDataAccess.ToPermissionsModel(),
                NormalizedName = data.Name.ToUpper(),
                Status         = RoleStatuses.Active,
                SqlWalletUser  = data.SqlWalletUser
            };

            _context.Roles.Add(role);
            _context.SaveChanges();

            return(RoleVm.Create(role));
        }
Beispiel #2
0
        /// <summary>
        /// Method for getting the role
        /// </summary>
        /// <param name = "id"> Id </param>
        /// <returns> </returns>
        public RoleVm GetRoleVmById(string id)
        {
            var role = GetRoleById(id);

            return(RoleVm.Create(role));
        }