Inheritance: ILookupCriteria
        public ActionResult Add(AddEditConstantsViewModel vModel)
        {
            string message = string.Empty;
            var authedUser = UserManager.FindById(User.Identity.GetUserId());

            var newObj = new NetMud.Data.System.Constants();
            newObj.Name = vModel.NewName;

            var criterion = new Dictionary<CriteriaType, string>();
            if (vModel.NewCriterionTypes != null && vModel.NewCriterionValues != null)
            {
                int nameIndex = 0;
                foreach (var criteriaType in vModel.NewCriterionTypes)
                {
                    if (criteriaType >= 0)
                    {
                        if (vModel.NewCriterionValues.Length <= nameIndex)
                            break;

                        var criteriaValue = vModel.NewCriterionValues[nameIndex];
                        if (!string.IsNullOrWhiteSpace(criteriaValue))
                            criterion.Add((CriteriaType)criteriaType, criteriaValue);
                    }

                    nameIndex++;
                }
            }

            var newValues = new HashSet<string>();
            if (vModel.NewConstantValues != null)
                foreach (var newValue in vModel.NewConstantValues)
                    if (!string.IsNullOrWhiteSpace(newValue) && !newValues.Contains(newValue))
                        newValues.Add(newValue);

            if(criterion == null || criterion.Count == 0 || newValues == null || newValues.Count == 0)
            {
                message = "You must supply at least one criteria and one value to create a new constant cluster.";
                return RedirectToAction("Index", new { Message = message });
            }

            var newLookup = new LookupCriteria();
            newLookup.Criterion = criterion;

            newObj.AddOrUpdate(newLookup, newValues);

            if (newObj.Create() == null)
                message = "Error; Creation failed.";
            else
            {
                LoggingUtility.LogAdminCommandUsage("*WEB* - AddConstantsFile[" + newObj.ID.ToString() + "]", authedUser.GameAccount.GlobalIdentityHandle);
                message = "Creation Successful.";
            }

            return RedirectToAction("Index", new { Message = message });
        }
        public ActionResult Edit(long id, AddEditConstantsViewModel vModel)
        {
            string message = string.Empty;
            var authedUser = UserManager.FindById(User.Identity.GetUserId());

            var obj = BackingDataCache.Get<IConstants>(id);
            if (obj == null)
            {
                message = "That does not exist";
                return RedirectToAction("Index", new { Message = message });
            }

            obj.Name = vModel.NewName;

            var criterion = new Dictionary<CriteriaType, string>();
            if (vModel.NewCriterionTypes != null && vModel.NewCriterionValues != null)
            {
                int nameIndex = 0;
                foreach (var criteriaType in vModel.NewCriterionTypes)
                {
                    if (criteriaType >= 0)
                    {
                        if (vModel.NewCriterionValues.Length <= nameIndex)
                            break;

                        var criteriaValue = vModel.NewCriterionValues[nameIndex];
                        if (!string.IsNullOrWhiteSpace(criteriaValue))
                            criterion.Add((CriteriaType)criteriaType, criteriaValue);
                    }

                    nameIndex++;
                }
            }

            var newValues = new HashSet<string>();
            if (vModel.NewConstantValues != null)
                foreach (var newValue in vModel.NewConstantValues)
                    if (!string.IsNullOrWhiteSpace(newValue) && !newValues.Contains(newValue))
                        newValues.Add(newValue);

            var newLookup = new LookupCriteria();
            newLookup.Criterion = criterion;

            obj.AddOrUpdate(newLookup, newValues);

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

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