Exemplo n.º 1
0
        public ActionResult AddDictata(string lexemeId, AddEditDictataViewModel vModel)
        {
            ApplicationUser authedUser = UserManager.FindById(User.Identity.GetUserId());

            ILexeme lex = ConfigDataCache.Get<ILexeme>(new ConfigDataCacheKey(typeof(ILexeme), lexemeId, ConfigDataType.Dictionary));
            if (lex == null)
            {
                return RedirectToAction("Index", new { Message = "That does not exist" });
            }

            IDictata newObj = vModel.DataObject;

            lex.AddNewForm(newObj);

            string message;
            if (lex.Save(authedUser.GameAccount, authedUser.GetStaffRank(User)))
            {
                LoggingUtility.LogAdminCommandUsage("*WEB* - AddDictata[" + newObj.UniqueKey + "]", authedUser.GameAccount.GlobalIdentityHandle);
                message = "Creation Successful.";
            }
            else
            {
                message = "Error; Creation failed.";
            }

            return RedirectToAction("Index", new { Message = message });
        }
Exemplo n.º 2
0
        public ActionResult RemoveDictata(string removeId = "", string authorizeRemove = "")
        {
            string message;
            if (!string.IsNullOrWhiteSpace(authorizeRemove) && removeId.Equals(authorizeRemove))
            {
                ApplicationUser authedUser = UserManager.FindById(User.Identity.GetUserId());

                ILexeme lex = ConfigDataCache.Get<ILexeme>(removeId.Substring(0, removeId.LastIndexOf("_") - 1));
                IDictata obj = lex?.WordForms?.FirstOrDefault(form => form.UniqueKey == removeId);

                if (obj == null)
                {
                    message = "That does not exist";
                }
                else 
                {
                    HashSet<IDictata> wordForms = lex.WordForms.ToHashSet();
                    wordForms.RemoveWhere(form => form.UniqueKey == removeId);
                    lex.WordForms = wordForms.ToArray();

                    lex.Save(authedUser.GameAccount, authedUser.GetStaffRank(User));
                    LoggingUtility.LogAdminCommandUsage("*WEB* - RemoveConstants[" + removeId + "]", authedUser.GameAccount.GlobalIdentityHandle);
                    message = "Delete Successful.";
                }
            }
            else
            {
                message = "You must check the proper remove or unapprove authorization radio button first.";
            }

            return RedirectToAction("Index", new { Message = message });
        }
Exemplo n.º 3
0
        public ActionResult Edit(string id, AddEditDictionaryViewModel vModel)
        {
            ApplicationUser authedUser = UserManager.FindById(User.Identity.GetUserId());

            ILexeme obj = ConfigDataCache.Get<ILexeme>(new ConfigDataCacheKey(typeof(ILexeme), id, ConfigDataType.Dictionary));
            string message;
            if (obj == null)
            {
                message = "That does not exist";
                return RedirectToAction("Index", new { Message = message });
            }

            obj.Name = vModel.DataObject.Name;
            obj.Language = vModel.DataObject.Language;

            if (obj.Save(authedUser.GameAccount, authedUser.GetStaffRank(User)))
            {
                LoggingUtility.LogAdminCommandUsage("*WEB* - EditLexeme[" + obj.UniqueKey + "]", authedUser.GameAccount.GlobalIdentityHandle);
                message = "Edit Successful.";
            }
            else
            {
                message = "Error; Edit failed.";
            }

            return RedirectToAction("Index", new { Message = message });
        }
Exemplo n.º 4
0
        public ActionResult Add(AddEditDictionaryViewModel vModel)
        {
            ApplicationUser authedUser = UserManager.FindById(User.Identity.GetUserId());

            ILexeme newObj = vModel.DataObject;
            string message;
            if (newObj.Save(authedUser.GameAccount, authedUser.GetStaffRank(User)))
            {
                LoggingUtility.LogAdminCommandUsage("*WEB* - AddLexeme[" + newObj.UniqueKey + "]", authedUser.GameAccount.GlobalIdentityHandle);
                message = "Creation Successful.";
            }
            else
            {
                message = "Error; Creation failed.";
            }

            return RedirectToAction("Index", new { Message = message });
        }
Exemplo n.º 5
0
        public ActionResult EditDictata(string lexemeId, string id, AddEditDictataViewModel vModel)
        {
            string message = string.Empty;
            ApplicationUser authedUser = UserManager.FindById(User.Identity.GetUserId());

            ILexeme lex = ConfigDataCache.Get<ILexeme>(new ConfigDataCacheKey(typeof(ILexeme), lexemeId, ConfigDataType.Dictionary));
            IDictata obj = lex?.WordForms?.FirstOrDefault(form => form.UniqueKey == id);

            if (obj == null)
            {
                message = "That does not exist";
                return RedirectToAction("Index", new { Message = message });
            }

            obj.Name = vModel.DataObject.Name;
            obj.Severity = vModel.DataObject.Severity;
            obj.Quality = vModel.DataObject.Quality;
            obj.Elegance = vModel.DataObject.Elegance;
            obj.Tense = vModel.DataObject.Tense;
            obj.Synonyms = vModel.DataObject.Synonyms;
            obj.Antonyms = vModel.DataObject.Antonyms;
            obj.PhraseSynonyms = vModel.DataObject.PhraseSynonyms;
            obj.PhraseAntonyms = vModel.DataObject.PhraseAntonyms;
            obj.Language = vModel.DataObject.Language;
            obj.WordType = vModel.DataObject.WordType;
            obj.Feminine = vModel.DataObject.Feminine;
            obj.Possessive = vModel.DataObject.Possessive;
            obj.Plural = vModel.DataObject.Plural;
            obj.Determinant = vModel.DataObject.Determinant;
            obj.Positional = vModel.DataObject.Positional;
            obj.Perspective = vModel.DataObject.Perspective;
            obj.Semantics = vModel.DataObject.Semantics;

            lex.AddNewForm(obj);

            if (lex.Save(authedUser.GameAccount, authedUser.GetStaffRank(User)))
            {
                foreach (IDictata syn in obj.Synonyms)
                {
                    if (!syn.Synonyms.Any(dict => dict == obj))
                    {
                        HashSet<IDictata> synonyms = syn.Synonyms;
                        synonyms.Add(obj);

                        ILexeme synLex = syn.GetLexeme();
                        syn.Synonyms = synonyms;

                        synLex.AddNewForm(syn);
                        synLex.Save(authedUser.GameAccount, authedUser.GetStaffRank(User));
                    }
                }

                foreach (IDictata ant in obj.Antonyms)
                {
                    if (!ant.Antonyms.Any(dict => dict == obj))
                    {
                        HashSet<IDictata> antonyms = ant.Antonyms;
                        antonyms.Add(obj);

                        ILexeme antLex = ant.GetLexeme();
                        ant.Antonyms = antonyms;
                        antLex.AddNewForm(ant);
                        antLex.Save(authedUser.GameAccount, authedUser.GetStaffRank(User));
                    }
                }

                foreach (IDictataPhrase syn in obj.PhraseSynonyms)
                {
                    if (!syn.Synonyms.Any(dict => dict == obj))
                    {
                        HashSet<IDictata> synonyms = syn.Synonyms;
                        synonyms.Add(obj);

                        syn.Synonyms = synonyms;
                        syn.Save(authedUser.GameAccount, authedUser.GetStaffRank(User));
                    }
                }

                foreach (IDictataPhrase ant in obj.PhraseAntonyms)
                {
                    if (!ant.Antonyms.Any(dict => dict == obj))
                    {
                        HashSet<IDictata> antonyms = ant.Antonyms;
                        antonyms.Add(obj);

                        ant.Antonyms = antonyms;
                        ant.Save(authedUser.GameAccount, authedUser.GetStaffRank(User));
                    }
                }

                LoggingUtility.LogAdminCommandUsage("*WEB* - EditDictata[" + obj.UniqueKey + "]", authedUser.GameAccount.GlobalIdentityHandle);
                message = "Edit Successful.";
            }
            else
            {
                message = "Error; Edit failed.";
            }

            return RedirectToAction("Index", new { Message = message });
        }
Exemplo n.º 6
0
        public ActionResult AddRelatedWord(string lexemeId, string id, AddEditDictataViewModel vModel)
        {
            ApplicationUser authedUser = UserManager.FindById(User.Identity.GetUserId());

            ILexeme lex = ConfigDataCache.Get<ILexeme>(new ConfigDataCacheKey(typeof(ILexeme), lexemeId, ConfigDataType.Dictionary));
            if (lex == null)
            {
                return RedirectToAction("Index", new { Message = "That does not exist" });
            }

            IDictata dict = lex.WordForms.FirstOrDefault(form => form.UniqueKey == id);
            if (dict == null)
            {
                return RedirectToAction("Index", new { Message = "That does not exist" });
            }

            Lexeme relatedLex = new Lexeme
            {
                Name = vModel.Word,
                Language = lex.Language
            };

            Dictata relatedWord = new Dictata()
            {
                Name = vModel.Word,
                Severity = dict.Severity + vModel.Severity,
                Quality = dict.Quality + vModel.Quality,
                Elegance = dict.Elegance + vModel.Elegance,
                Tense = dict.Tense,
                Language = dict.Language,
                WordType = dict.WordType,
                Feminine = dict.Feminine,
                Possessive = dict.Possessive,
                Plural = dict.Plural,
                Determinant = dict.Determinant,
                Positional = dict.Positional,
                Perspective = dict.Perspective,
                Semantics = dict.Semantics
            };

            HashSet<IDictata> synonyms = dict.Synonyms;
            synonyms.Add(dict);

            if (vModel.Synonym)
            {
                relatedWord.Synonyms = synonyms;
                relatedWord.Antonyms = dict.Antonyms;
                relatedWord.PhraseSynonyms = dict.PhraseSynonyms;
                relatedWord.PhraseAntonyms = dict.PhraseAntonyms;
            }
            else
            {
                relatedWord.Synonyms = dict.Antonyms;
                relatedWord.Antonyms = synonyms;
                relatedWord.PhraseSynonyms = dict.PhraseAntonyms;
                relatedWord.PhraseAntonyms = dict.PhraseSynonyms;
            }

            relatedLex.AddNewForm(relatedWord);

            string message;
            if (relatedLex.Save(authedUser.GameAccount, authedUser.GetStaffRank(User)))
            {
                if (vModel.Synonym)
                {
                    HashSet<IDictata> mySynonyms = dict.Synonyms;
                    mySynonyms.Add(relatedWord);

                    dict.Synonyms = mySynonyms;
                }
                else
                {
                    HashSet<IDictata> antonyms = dict.Antonyms;
                    antonyms.Add(relatedWord);

                    dict.Antonyms = antonyms;
                }

                lex.Save(authedUser.GameAccount, authedUser.GetStaffRank(User));
                relatedLex.Save(authedUser.GameAccount, authedUser.GetStaffRank(User));

                LoggingUtility.LogAdminCommandUsage("*WEB* - EditLexeme[" + lex.UniqueKey + "]", authedUser.GameAccount.GlobalIdentityHandle);
                message = "Edit Successful.";
            }
            else
            {
                message = "Error; Edit failed.";
            }

            return RedirectToAction("Index", new { Message = message });
        }