Ejemplo n.º 1
0
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            /// <summary>
            /// Creates the user roles when the application starts
            /// if they don't exist already
            /// </summary>
            ManageRoles manager = new ManageRoles();

            if (!manager.RoleExists("Administrator"))
            {
                manager.CreateRole("Administrator");
            }
            if (!manager.RoleExists("Student"))
            {
                manager.CreateRole("Student");
            }
            if (!manager.RoleExists("Teacher"))
            {
                manager.CreateRole("Teacher");
            }
        }
Ejemplo n.º 2
0
        public async Task <IHttpActionResult> PutRolesMaster(int id, Roles role)
        {
            if (id != role.Id)
            {
                return(BadRequest());
            }

            try
            {
                await roles.PutRolesMaster(role);
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!roles.RoleExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }