コード例 #1
0
        public async Task <ActionResult> Create(
            [Bind(Include = "Name,Description")] Group applicationgroup, params string[] selectedRoles)
        {
            if (ModelState.IsValid)
            {
                var result = await GroupManager.CreateGroupAsync(applicationgroup);

                if (result.Succeeded)
                {
                    selectedRoles = selectedRoles ?? new string[] {};
                    await GroupManager.SetGroupRolesAsync(applicationgroup.Id, selectedRoles);
                }

                return(RedirectToAction("Index"));
            }

            ViewBag.RoleId = new SelectList(
                RoleManager.Roles.ToList(), "Id", "Name");
            return(View(applicationgroup));
        }
コード例 #2
0
ファイル: GroupsController.cs プロジェクト: nasraldin/ETCTask
        public async Task <ActionResult> Create(
            [Bind(Include = "Name,Description")] Group applicationgroup, params string[] selectedRoles)
        {
            if (ModelState.IsValid)
            {
                var result = await GroupManager.CreateGroupAsync(applicationgroup);

                if (result.Succeeded)
                {
                    selectedRoles = selectedRoles ?? new string[] {};
                    await GroupManager.SetGroupRolesAsync(applicationgroup.Id, selectedRoles);
                }
                var url = Url.Action("Index", "Groups");
                return(Json(new { success = true, url }));
            }

            ViewBag.RoleId = new SelectList(
                RoleManager.Roles.ToList(), "Id", "Name");
            return(PartialView("_Create", applicationgroup));
        }
コード例 #3
0
        public async void Initialize()
        {
            try
            {
                if (!string.IsNullOrEmpty(CustomPath))
                {
                    RootPath = CustomPath;
                }
                else
                {
                    RootPath = Directory.GetCurrentDirectory() + "\\Redox\\";
                }

                PluginPath     = Path.Combine(RootPath, "Plugins\\");
                ExtensionPath  = Path.Combine(RootPath, "Extensions\\");
                DependencyPath = Path.Combine(RootPath, "Dependencies\\");
                DataPath       = Path.Combine(RootPath, "Data\\");
                LoggingPath    = Path.Combine(RootPath, "Logs\\");
                AssemblePath   = Path.GetDirectoryName(assembly.Location);



                if (!Directory.Exists(RootPath))
                {
                    Directory.CreateDirectory(RootPath);
                }
                if (!Directory.Exists(LoggingPath))
                {
                    Directory.CreateDirectory(LoggingPath);
                }
                if (!Directory.Exists(ExtensionPath))
                {
                    Directory.CreateDirectory(ExtensionPath);
                }
                if (!Directory.Exists(DependencyPath))
                {
                    Directory.CreateDirectory(DependencyPath);
                }
                if (!Directory.Exists(PluginPath))
                {
                    Directory.CreateDirectory(PluginPath);
                }
                if (!Directory.Exists(DataPath))
                {
                    Directory.CreateDirectory(DataPath);
                }

                Config = new RedoxConfig();
                string path = Path.Combine(RootPath, "Redox.json");
                if (File.Exists(path))
                {
                    Config = Utility.Json.FromFile <RedoxConfig>(path);
                }
                else
                {
                    Utility.Json.ToFile(path, Config.Init());
                }

                this.EnableCertificates();
                this.LoadDependencies();
                ExtensionLoader.Load();
                this.Container = ContainerConfig.Configure();
                this.BuildContainer();
                Logger = Container.Resolve <ILogger>();
                Logger.LogInfo("[Redox] Initializing RedoxMod..");
                PluginEngineManager.Register <CSPluginEngine>();
                Logger.LogInfo("[Redox] Loading data...");

                await PermissionManager.LoadAsync();

                await GroupManager.LoadAsync();

                await RoleManager.LoadAsync();

                await RoleManager.CreateRoleAsync(new Role("default", "default role", 0, false));

                await GroupManager.CreateGroupAsync(new Group("default", "default group for players.", "default", 0, true, false));

                await RoleManager.AddGroupAsync("default", "default");

                Logger.LogInfo("[Redox] Loading standard library..");
                LocalStorage.Load();
                PluginCollector.GetCollector();
                Logger.LogInfo($"[Redox] RedoxMod V{Version} has been initialized.");
            }
            catch (Exception ex)
            {
                Console.Clear();
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine(string.Format("[Error] Failed to load Redox, Error: {0}", ex));
            }
            LifeTimeWatch   = Stopwatch.StartNew();
            WebRequestTimer = Timers.Create(5, TimerType.Repeat, WebRequestUpdate);
        }