Exemple #1
0
        public JsonResult <IEnumerable <Tuple <IUIModule, int> > > LoadUIModules()
        {
            ApplicationUser user = UserManager.FindById(User.Identity.GetUserId());

            Data.Players.Account account = user.GameAccount;

            if (account == null)
            {
                return(null);
            }

            return(Json(account.Config.UIModules));
        }
Exemple #2
0
        public string RemoveUIModuleContent(string moduleName, int location)
        {
            ApplicationUser user = UserManager.FindById(User.Identity.GetUserId());

            Data.Players.Account account = user.GameAccount;

            if (account == null)
            {
                return("Invalid Account.");
            }

            List <Tuple <IUIModule, int> > modules = account.Config.UIModules.ToList();

            if (moduleName == "**anymodule**" && location != -1)
            {
                if (modules.Any(mod => mod.Item2.Equals(location)))
                {
                    Tuple <IUIModule, int> moduleTuple = modules.FirstOrDefault(mod => mod.Item2.Equals(location));
                    modules.Remove(moduleTuple);
                }
            }
            else
            {
                IUIModule module = TemplateCache.GetByName <IUIModule>(moduleName);

                if (module == null)
                {
                    return("Invalid Module.");
                }

                if ((location < 1 && location != -1) || location > 4)
                {
                    return("Invalid Location");
                }

                Tuple <IUIModule, int> moduleTuple = new Tuple <IUIModule, int>(module, location);

                //Remove this module
                if (modules.Any(mod => mod.Item1.Equals(module) && mod.Item2.Equals(location)))
                {
                    modules.Remove(moduleTuple);
                }
            }

            account.Config.UIModules = modules;
            account.Config.Save(account, StaffRank.Player);

            return("Success");
        }
Exemple #3
0
        public JsonResult <string[]> GetUIModuleNames(string term)
        {
            ApplicationUser user = UserManager.FindById(User.Identity.GetUserId());

            Data.Players.Account account = user.GameAccount;

            if (account == null)
            {
                return(Json(new string[0]));
            }

            IEnumerable <IUIModule> modules = TemplateCache.GetAll <IUIModule>(true).Where(uim => uim.Name.Contains(term));

            return(Json(modules.Select(mod => mod.Name).ToArray()));
        }
Exemple #4
0
        public string SaveUIModuleContent(string moduleName, int location)
        {
            ApplicationUser user = UserManager.FindById(User.Identity.GetUserId());

            Data.Players.Account account = user.GameAccount;

            if (account == null)
            {
                return("Invalid Account.");
            }

            IUIModule module = TemplateCache.GetByName <IUIModule>(moduleName);

            if (module == null)
            {
                return("Invalid Module.");
            }

            if ((location < 1 && location != -1) || location > 4)
            {
                return("Invalid Location");
            }

            List <Tuple <IUIModule, int> > modules     = account.Config.UIModules.ToList();
            Tuple <IUIModule, int>         moduleTuple = new Tuple <IUIModule, int>(module, location);

            //Remove this module
            if (modules.Any(mod => mod.Item1.Equals(module)))
            {
                modules.Remove(moduleTuple);
            }

            //Remove the module in its place
            if (location != -1 && modules.Any(mod => mod.Item2.Equals(location)))
            {
                modules.RemoveAll(mod => mod.Item2.Equals(location));
            }

            //Add it finally
            modules.Add(moduleTuple);

            account.Config.UIModules = modules;

            account.Config.Save(account, StaffRank.Player);

            return("Success");
        }