Пример #1
0
 public override IIndexer SetIndex(IIndexModel model)
 {
     using (var entityRepository = ResolverFactory.Resolve <EntityRepository>())
     {
         AttributeModel = model as AttributeModel;
         EntityModel    = entityRepository.GetById(AttributeModel.EntityId.ToString());
         SpreadOptions();
         return(this);
     }
 }
        private void AddNewRequirementRecord()
        {
            RequirementModel reqModel;
            string           tableName;
            string           applyToName;

            reqModel    = new RequirementModel();
            tableName   = comboCategory.SelectedItem.ToString();
            applyToName = comboApplyTo.SelectedItem.ToString();

            reqModel.TableNamesId = TableNamesModel.GetIdFromTableName(tableName);
            if (tableName == "Ability")
            {
                reqModel.ApplytoId = AbilityModel.GetIdFromName(applyToName);
            }
            else if (tableName == "Alignments")
            {
                reqModel.ApplytoId = AlignmentModel.GetIdFromName(applyToName);
            }
            else if (tableName == "Attribute")
            {
                reqModel.ApplytoId = AttributeModel.GetIdFromName(applyToName);
            }
            else if (tableName == "Class")
            {
                reqModel.ApplytoId = ClassModel.GetIdFromName(applyToName);
            }
            else if (tableName == "Enhancement")
            {
                reqModel.ApplytoId = GetEnhancementId();
            }
            else if (tableName == "EnhancementSlot")
            {
                reqModel.ApplytoId = GetSlotId();
            }
            else if (tableName == "Feat")
            {
                reqModel.ApplytoId = FeatModel.GetIdFromName(applyToName);
            }
            else if (tableName == "Race")
            {
                reqModel.ApplytoId = RaceModel.GetIdFromName(applyToName);
            }
            else if (tableName == "Skill")
            {
                reqModel.ApplytoId = SkillModel.GetIdFromName(applyToName);
            }
            else
            {
                Debug.WriteLine("Error: CategoryName isn't listed :: RequirementDialogClass: AddNewRequirement");
            }

            reqModel.Save();
            SelectedRequirementId = reqModel.Id;
        }
        private string GetAttributeMapping(AttributeModel attribute)
        {
            var statements = new List<string>();
            statements.Add($"builder.Property(x => x.{ attribute.Name.ToPascalCase() })");
            if (!attribute.Type.IsNullable)
            {
                statements.Add(".IsRequired()");
            }

            if (attribute.GetPrimaryKey()?.Identity() == true)
            {
                statements.Add(".UseSqlServerIdentityColumn()");
            }

            if (attribute.GetDefaultConstraint()?.Value() != null)
            {
                var defaultValue = attribute.GetDefaultConstraint().Value();
                statements.Add($".HasDefaultValueSql({(attribute.Type.Element.Name == "string" ? $"\"{ defaultValue }\"" : defaultValue)})");
            }

            var maxLength = attribute.GetTextConstraints()?.MaxLength();
            if (maxLength.HasValue && attribute.Type.Element.Name == "string")
            {
                statements.Add($".HasMaxLength({maxLength.Value})");
            }

            var decimalPrecision = attribute.GetDecimalConstraints()?.Precision();
            var decimalScale = attribute.GetDecimalConstraints()?.Scale();
            var columnType = attribute.GetColumn()?.Type();
            if (decimalPrecision.HasValue && decimalScale.HasValue)
            {
                statements.Add($".HasColumnType(\"decimal({ decimalPrecision }, { decimalScale })\")");
            }
            else if (!string.IsNullOrWhiteSpace(columnType))
            {
                statements.Add($".HasColumnType(\"{columnType}\")");
            }

            var columnName = attribute.GetColumn()?.Name();
            if (!string.IsNullOrWhiteSpace(columnName))
            {
                statements.Add($".HasColumnName(\"{columnName}\")");
            }

            var computedValueSql = attribute.GetComputedValue()?.SQL();
            if (!string.IsNullOrWhiteSpace(computedValueSql))
            {
                statements.Add($".HasComputedColumnSql(\"{computedValueSql}\"{(attribute.GetComputedValue().Stored() ? ", stored: true" : string.Empty)})");
            }

            return $@"
            {string.Join(@"
                ", statements)};";
        }
Пример #4
0
 private void ddlParentAttributes_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     if (ddlParentAttributes.SelectedItem != null)
     {
         GridSelectColumnsVisibility();
         AttributeModel             objAttributeModel = (AttributeModel)ddlParentAttributes.SelectedItem;
         List <AttributeValueModel> lAttributeValues  = objDataAccess.GetAttributeValueByAttributeId(objAttributeModel.AttributeId);
         dGridAttributesValues.ItemsSource = lAttributeValues;
         GetAttributeValues();
     }
 }
Пример #5
0
        public AttributeModel UpdateAttributeStatus(AttributeModel attributeModel)
        {
            var attribute = new NAGGLE.DAL.Entities.Attribute();

            Mapper.Map(attributeModel, attribute);
            _unitOfWork.attributeRespository.Update(attribute);
            _unitOfWork.Save();
            Mapper.Map(attribute, attributeModel);

            return(attributeModel);
        }
Пример #6
0
        protected void Page_Load(object sender, EventArgs e)
        {
            this.attributeID = this.Request.QueryString["AttributeID"].ToInt32();

            if (!this.IsPostBack)
            {
                AttributeModel   model = userManager.ReadAttribute(this.attributeID);
                List <IDataItem> list  = model.ToDataItem();
                this.SetControlValue(list);
            }
        }
Пример #7
0
 public ActionResult Create(AttributeModel model, bool continueEditing)
 {
     if (ModelState.IsValid)
     {
         var entity = model.MapTo <Attribute>();
         model.Id = _attributeService.InsertAttribute(entity);
         return(continueEditing ? RedirectToAction("Edit", new { id = model.Id }) : RedirectToAction("List"));
     }
     PrepareAttributeModel(model);
     return(View(model));
 }
Пример #8
0
        private IEnumerable <OptionItem> GetPusherTemplateOptions(EntityModel e, AttributeModel a)
        {
            if (string.IsNullOrWhiteSpace(a.DestinationConnectionId.ToString()) || a.DestinationConnectionId == Guid.Empty)
            {
                return(new List <OptionItem>());
            }
            var conn   = connectionRepository.GetById(a.DestinationConnectionId.ToString());
            var pusher = pushers.FirstOrDefault(p => p.IsImplemented(a.DestinationProcessorId, e.DestinationProcessorId, conn.ProviderId));

            return(pusher?.Options ?? new List <OptionItem>());
        }
        public IActionResult AddAttributes([FromBody] AttributeModel model)
        {
            var sensor = new Sensor(Guid.NewGuid(), "Dinning Room Temp", 73.04M);

            foreach (AttributeValue attribute in model.Attributes)
            {
                sensor.Attributes.SetValue(attribute.Name, attribute.Value);
            }

            return(Ok(sensor));
        }
Пример #10
0
        public static DbTextModel DbText2Model(DBText dbText, AttributeModel atModel)
        {
            DbTextModel dbModel = new DbTextModel();

            dbModel.attItemList = new List <AttributeItemModel>();
            dbModel.Height      = dbText.Height;
            //dbModel.Position = new System.Drawing.PointF((float)dbText.Position.X, (float)dbText.Position.Y);
            dbModel.Position  = Point3d2Pointf(dbText.Position);
            dbModel.Rotation  = dbText.Rotation;
            dbModel.ThickNess = dbText.Thickness;
            dbModel.Text      = dbText.TextString.Replace(" ", "").Replace("\n", "").Replace("\r", "");
            if (dbText.TextString.Replace("      ", "").Replace("\n", "").Replace("\r", "") == "纬三路")
            {
            }
            dbModel.Color = dbText.ColorIndex == 256 ? MethodCommand.GetLayerColorByID(dbText.LayerId) : System.Drawing.ColorTranslator.ToHtml(dbText.Color.ColorValue);
            foreach (AttributeItemModel item in atModel.attributeItems)
            {
                string attValue = "";

                switch (item.AtItemType)
                {
                case AttributeItemType.TxtHeight:
                    attValue = dbText.Height.ToString();
                    break;

                case AttributeItemType.Color:
                    attValue = dbModel.Color;
                    break;

                case AttributeItemType.Content:
                    attValue = dbText.TextString.Replace(" ", "").Replace("      ", "").Replace("\n", "").Replace("\r", "");
                    break;

                case AttributeItemType.LayerName:
                    attValue = dbText.Layer;
                    break;

                case AttributeItemType.LineScale:
                    attValue = dbText.LinetypeScale.ToString();
                    break;

                case AttributeItemType.LineType:
                    attValue = GetLayerLineTypeByID(dbText);
                    break;
                }
                if (!string.IsNullOrEmpty(attValue))
                {
                    item.AtValue = attValue;
                    dbModel.attItemList.Add(item);
                }
            }
            return(dbModel);
        }
Пример #11
0
        public JsonResult UpdateAttributeStatus(AttributeViewModel attributeViewModel)
        {
            var attributeModel = new AttributeModel();

            Mapper.Map(attributeViewModel, attributeModel);
            var att = _productService.UpdateAttributeStatus(attributeModel);

            Mapper.Map(att, attributeViewModel);


            return(Json(attributeViewModel, JsonRequestBehavior.AllowGet));
        }
Пример #12
0
 public async Task <ActionResult> UpdateAttribute(OutModels.Models.Attribute attribute)
 {
     try
     {
         AttributeModel am = (AttributeModel)_mapper.Map <OutModels.Models.Attribute, AttributeModel>(attribute);
         return(new JsonResult(await this._repository.Update(am)));
     }
     catch (Exception ex)
     {
         return(null);
     }
 }
Пример #13
0
        /*Get Specific Attribute Detail By id*/
        public AttributeModel GetAttributeById(int attributeId)
        {
            var attributeModel = new AttributeModel();

            var attribute = _unitOfWork.attributeRespository.Get(m => m.AttributeId == attributeId).FirstOrDefault();

            Mapper.Map(attribute, attributeModel);

            Mapper.Map(attribute.AttributeCategory, attributeModel.AttributeCategoryModel);

            return(attributeModel);
        }
Пример #14
0
        private async Task WriteAttributeContentAsync(AttributeModel attribute)
        {
            await this.TextWriter.WriteAsync(attribute.TypeName);

            if (attribute.Arguments.Any())
            {
                await this.TextWriter.WriteAsync("(");

                await this.TextWriter.WriteAsync(string.Join(", ", attribute.Arguments.Select(this.FormatAttributeLiteral)));

                await this.TextWriter.WriteAsync(")");
            }
        }
Пример #15
0
        /// <summary>
        /// Base function to handle skyline preferences
        /// </summary>
        /// <returns></returns>
        private PrefSQLModel AddSkyline(AttributeModel attributeModel)
        {
            //Add the preference to the list
            PrefSQLModel pref = new PrefSQLModel();

            pref.Skyline.Add(attributeModel);
            pref.NumberOfRecords        = _numberOfRecords;
            pref.Tables                 = _tables;
            pref.WithIncomparable       = _hasIncomparableTuples;
            pref.ContainsOpenPreference = _containsOpenPreference;
            Model = pref;
            return(pref);
        }
Пример #16
0
 public IActionResult ExecuteEncrpytion([FromBody] CRUDAttributeDTO lstAttributes)
 {
     if (ModelState.IsValid)
     {
         encryptionRepository.LoadContext(lstAttributes.OrgCode, distributedCache);
         var model = new AttributeModel();
         model.tblVocattributes = lstAttributes.Attributes;
         model.UserName         = User.Claims.FirstOrDefault(x => x.Type == ClaimTypes.NameIdentifier).Value;
         var result = encryptionRepository.UpdateEncrpytion(model, lstAttributes.OrgCode);
         return(StatusCode(result.StatusCode, new { data = result.Response }));
     }
     return(StatusCode(400));
 }
Пример #17
0
        public ActionResult InsertAttribute(AttributeModel model)
        {
            int k = categoryandproduct.InsertAttribute(model);

            if (k > 0)
            {
                return(Json("1", JsonRequestBehavior.DenyGet));
            }
            else
            {
                return(Json("0", JsonRequestBehavior.DenyGet));
            }
        }
        private Guid GetApplyToId()
        {
            Guid   applyToId;
            string tableName;

            applyToId = Guid.Empty;
            tableName = comboCategory.SelectedItem.ToString();

            if (tableName == "Ability")
            {
                applyToId = AbilityModel.GetIdFromName(comboApplyTo.SelectedItem.ToString());
            }
            if (tableName == "Alignments")
            {
                applyToId = AlignmentModel.GetIdFromName(comboApplyTo.SelectedItem.ToString());
            }
            if (tableName == "Attribute")
            {
                applyToId = AttributeModel.GetIdFromName(comboApplyTo.SelectedItem.ToString());
            }
            if (tableName == "Character")
            {
                applyToId = Guid.Empty;
            }
            if (tableName == "Class")
            {
                applyToId = ClassModel.GetIdFromName(comboApplyTo.SelectedItem.ToString());
            }
            if (tableName == "Enhancement")
            {
                applyToId = GetEnhancementId();
            }
            if (tableName == "EnhancementSlot")
            {
                applyToId = GetSlotId();
            }
            if (tableName == "Feat")
            {
                applyToId = FeatModel.GetIdFromName(comboApplyTo.SelectedItem.ToString());
            }
            if (tableName == "Race")
            {
                applyToId = RaceModel.GetIdFromName(comboApplyTo.SelectedItem.ToString());
            }
            if (tableName == "Skill")
            {
                applyToId = SkillModel.GetIdFromName(comboApplyTo.SelectedItem.ToString());
            }

            return(applyToId);
        }
Пример #19
0
        public void AttributeModelHasDefaultValues()
        {
            DateTime testStartDate = DateTime.UtcNow;
            Dictionary <string, AttributeModel> attrs = typeof(AttributeTestModel).GetAttributes();

            Assert.AreEqual("Test Default Value", attrs["TestDefault"].DefaultValue);
            AttributeModel startDateAttr = attrs["TestStartDate"];

            Assert.IsTrue(startDateAttr.DefaultValue is DateTime, "Check default value is datetime");
            var startDate = (DateTime)startDateAttr.DefaultValue;

            Assert.IsTrue(startDate >= testStartDate, "Check that date set is sometime after the start of the test");
            Assert.IsTrue(startDate <= DateTime.UtcNow, "Check that date set is sometime before the end of the test");
        }
Пример #20
0
 /// <summary>
 /// Method to add an attribute to the model class
 /// </summary>
 public void AddClassAttribute(AttributeModel attribute)
 {
     if (attribute.Arguments != null && attribute.Arguments.Length != 0)
     {
         this.targetClass.CustomAttributes.Add(
             new CodeAttributeDeclaration(
                 attribute.Name,
                 attribute.GetArguments()));
     }
     else
     {
         this.targetClass.CustomAttributes.Add(new CodeAttributeDeclaration(attribute.Name));
     }
 }
Пример #21
0
        private void FillcomboModifier()
        {
            string categoryName;

            categoryName = comboCategory.SelectedItem.ToString();
            ModifierNames.Clear();
            comboModifier.Items.Clear();

            if (categoryName == "Ability")
            {
                labelModifier.Text = "Select an Ability";
                ModifierNames      = AbilityModel.GetNames();
            }
            else if (categoryName == "Attribute")
            {
                labelModifier.Text = "Select an Attribute";
                ModifierNames      = AttributeModel.GetNames();
            }
            else if (categoryName == "Feat")
            {
                labelModifier.Text = "Select a Feat";
                ModifierNames      = FeatModel.GetNames();
            }
            else if (categoryName == "Save")
            {
                labelModifier.Text = "Select a Save";
                ModifierNames      = SaveModel.GetNames();
            }
            else if (categoryName == "Skill")
            {
                labelModifier.Text = "Select a Skill";
                ModifierNames      = SkillModel.GetNames();
            }
            else if (categoryName == "Spell")
            {
                labelModifier.Text = "Select a Spell";
                ModifierNames      = SpellModel.GetNames();
            }
            else
            {
                //We should never reach this, if so, we need to add a category of fix one.
                Debug.WriteLine("Error: no category exist for the selected. ModifierDialogClass::FillcomboModifier()");
                return;
            }

            foreach (string name in ModifierNames)
            {
                comboModifier.Items.Add(name);
            }
        }
        /// <summary>
        /// Gets the attribute collection.
        /// </summary>
        /// <param name="xmlData">
        /// The XML data.
        /// </param>
        /// <returns>
        /// </returns>
        private OCAttributeModelCollection GetAttributeCollection(XElement xmlData)
        {
            OCAttributeModelCollection t = new OCAttributeModelCollection();

            // Get colour
            Application.Current.Resources.TryGetValue("CardBackGroundAttribute", out var varCardColour);
            Color cardColour = (Color)varCardColour;

            // Run query
            var theERElement =
                from orElementEl
                in xmlData.Elements(ns + "attribute")
                select orElementEl;

            if (theERElement.Any())
            {
                // Load attribute object references
                foreach (XElement theLoadORElement in theERElement)
                {
                    AttributeModel newAttributeModel = new AttributeModel
                    {
                        Handle = "AttributeCollection",

                        GCitationReferenceCollection = GetCitationCollection(theLoadORElement),

                        GNoteModelReferenceCollection = GetNoteCollection(theLoadORElement),

                        Priv = SetPrivateObject(GetAttribute(theLoadORElement.Attribute("priv"))),

                        GType = GetAttribute(theLoadORElement.Attribute("type")),

                        GValue = GetAttribute(theLoadORElement.Attribute("value")),
                    };

                    // set the Home image or symbol
                    newAttributeModel.HomeImageHLink.HomeImageType    = CommonConstants.HomeImageTypeSymbol;
                    newAttributeModel.HomeImageHLink.HomeSymbol       = CommonConstants.IconAttribute;
                    newAttributeModel.HomeImageHLink.HomeSymbolColour = cardColour;

                    t.Add(newAttributeModel);
                }
            }

            // Return sorted by the default text
            t.Sort(T => T.DeRef.GetDefaultText);

            return(t);
        }
Пример #23
0
        private void ddlAttributeType_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            JobManager.DAL.DataAccess objDataAccess = new JobManager.DAL.DataAccess();


            AttributeTypeModel objAttributeTypeModel = (AttributeTypeModel)((ComboBox)sender).SelectedItem;

            if (objAttributeTypeModel.AttributeTypeId == 2)
            {
                lblParentAttribute.Content = "Parent Attribute";
                List <AttributeModel> lAttributeModels  = objDataAccess.GetAttributeByType(2);
                AttributeModel        objAttributeModel = new AttributeModel();
                ddlParentAttributes.DisplayMemberPath = nameof(objAttributeModel.AttributeName);
                ddlParentAttributes.SelectedValuePath = nameof(objAttributeModel.AttributeId);
                ddlParentAttributes.ItemsSource       = lAttributeModels;

                if (dAttributeName.SelectedValue != null) // New Value
                {
                    // Assign Parent Value Here
                    AttributeModel objParentAttributeModel = objDataAccess.GetAttributeByAttributeId(Convert.ToInt32(dAttributeName.SelectedValue));
                    if (objParentAttributeModel.ParentId != 0)
                    {
                        ddlParentAttributes.SelectedValue = objParentAttributeModel.ParentId;
                    }
                    else
                    {
                        // Clear Grid and load Attribute Values
                    }
                }
                else
                {
                    List <NewAttributeGrid> lNewAttributeGrid = new List <NewAttributeGrid>();
                    dGridNewAttributes.ItemsSource = lNewAttributeGrid;
                }


                ddlParentAttributes.Visibility = Visibility.Visible;
                dGridNewAttributes.Visibility  = Visibility.Visible;
                txtParentAttribute.Visibility  = Visibility.Collapsed;
            }
            else
            {
                lblParentAttribute.Content     = "Attribute Value";
                txtParentAttribute.Visibility  = Visibility.Visible;
                ddlParentAttributes.Visibility = Visibility.Collapsed;
                dGridNewAttributes.Visibility  = Visibility.Collapsed;
            }
        }
Пример #24
0
        public void AttributeModelGreaterThanMessageIsCorrectInDifferentCulture()
        {
            var savedCulture = Thread.CurrentThread.CurrentUICulture;

            Thread.CurrentThread.CurrentUICulture = new CultureInfo("es");
            Dictionary <string, AttributeModel> attrs = typeof(AttributeTestModel).GetAttributes();
            AttributeModel testAttr = attrs["TestEndDate"];

            Assert.IsTrue(testAttr.Validations.ContainsKey("MustBeGreaterThan"));
            ValidationAttribute val = testAttr.Validations["MustBeGreaterThan"];

            Assert.AreEqual("Prueba Fecha de finalización debe ser mayor que Prueba Fecha de Inicio", val.ErrorMessage);

            // Set it back at the end of the test so it doesn't affect other tests.
            Thread.CurrentThread.CurrentUICulture = savedCulture;
        }
Пример #25
0
        public TypeModel Analyze()
        {
            var attributes = this.attributeInstantiator.Instantiate(this.namedTypeSymbol, this.diagnosticReporter).ToList();
            var typeAndInterfaceAttributes = attributes.Concat(
                this.namedTypeSymbol.AllInterfaces.SelectMany(x => this.attributeInstantiator.Instantiate(x, this.diagnosticReporter))).ToList();

            var typeModel = new TypeModel(this.namedTypeSymbol)
            {
                SerializationMethodsAttribute = Get <SerializationMethodsAttribute>(),
                BaseAddressAttribute          = Get <BaseAddressAttribute>(),
                BasePathAttribute             = Get <BasePathAttribute>(),
                IsAccessible = this.compilation.IsSymbolAccessibleWithin(this.namedTypeSymbol, this.compilation.Assembly)
            };

            typeModel.HeaderAttributes.AddRange(GetAll <HeaderAttribute>());
            typeModel.AllowAnyStatusCodeAttributes.AddRange(GetAll <AllowAnyStatusCodeAttribute>());

            foreach (var member in this.InterfaceAndParents().SelectMany(x => x.GetMembers()))
            {
                switch (member)
                {
                case IPropertySymbol property:
                    typeModel.Properties.Add(this.GetProperty(property));
                    break;

                case IMethodSymbol method when method.MethodKind == MethodKind.Ordinary:
                    typeModel.Methods.Add(this.GetMethod(method));
                    break;

                case IEventSymbol evt:
                    typeModel.Events.Add(new EventModel(evt));
                    break;
                }
            }

            return(typeModel);

            AttributeModel <T>?Get <T>() where T : Attribute
            {
                var(attribute, attributeData, type) = attributes.FirstOrDefault(x => x.attribute is T);
                return(attribute == null ? null : AttributeModel.Create((T)attribute, attributeData, type));
            }

            IEnumerable <AttributeModel <T> > GetAll <T>() where T : Attribute =>
            typeAndInterfaceAttributes.Where(x => x.attribute is T)
            .Select(x => AttributeModel.Create((T)x.attribute !, x.attributeData, x.declaringSymbol));
        }
Пример #26
0
        public ActionResult Edit(int?id)
        {
            var category       = _attribute.GetById(id);
            var attributeModel = new AttributeModel();

            attributeModel.Id       = category.Id;
            attributeModel.Name     = category.Name;
            attributeModel.Status   = category.Status;
            attributeModel.CreateBy = category.CreateBy.ToString();
            attributeModel.UpdateBy = category.UpdateBy;
            attributeModel.CreateAt = category.CreateAt;
            attributeModel.UpdateAt = category.UpdateAt;
            attributeModel.TypeId   = category.TypeId;
            attributeModel.Value    = category.Value;

            return(View(attributeModel));
        }
Пример #27
0
        public ActionResult AddAttribute(int cateId = -1)
        {
            CategoryInfo categoryInfo = AdminCategories.GetCategoryById(cateId);

            if (categoryInfo == null)
            {
                return(PromptView("分类不存在"));
            }

            AttributeModel model = new AttributeModel();

            ViewData["cateId"]             = categoryInfo.CateId;
            ViewData["categoryName"]       = categoryInfo.Name;
            ViewData["attributeGroupList"] = GetAttributeGroupSelectList(cateId);
            ViewData["referer"]            = ShopUtils.GetAdminRefererCookie();
            return(View(model));
        }
Пример #28
0
 public bool ModifyAttribute(AttributeModel objAttributeModel)
 {
     try
     {
         int?      iParentId    = objAttributeModel.ParentId == 0 ? null : (int?)objAttributeModel.ParentId;
         Attribute objAttribute = jmdc.Attributes.Where(p => p.Id == objAttributeModel.AttributeId).SingleOrDefault();
         objAttribute.Name     = objAttributeModel.AttributeName;
         objAttribute.ParentId = iParentId;
         jmdc.SubmitChanges();
         objAttributeModel.AttributeId = objAttribute.Id;
         return(true);
     }
     catch (Exception)
     {
         return(false);
     }
 }
        private void AddModifierRecord()
        {
            ModifierModel model;
            string        categoryName;
            string        applyToName;

            categoryName = CategoryComboBox.SelectedItem.ToString();
            applyToName  = ApplyToComboBox.SelectedItem.ToString();

            model = new ModifierModel();
            model.Initialize(Guid.Empty);
            model.TableNamesId = TableNamesModel.GetIdFromTableName(categoryName);
            if (categoryName == "Ability")
            {
                model.ApplyToId = AbilityModel.GetIdFromName(applyToName);
            }
            else if (categoryName == "Attribute")
            {
                model.ApplyToId = AttributeModel.GetIdFromName(applyToName);
            }
            else if (categoryName == "Feat")
            {
                model.ApplyToId = AttributeModel.GetIdFromName(applyToName);
            }
            else if (categoryName == "Save")
            {
                model.ApplyToId = AttributeModel.GetIdFromName(applyToName);
            }
            else if (categoryName == "Skill")
            {
                model.ApplyToId = AttributeModel.GetIdFromName(applyToName);
            }
            else if (categoryName == "Spell")
            {
                model.ApplyToId = AttributeModel.GetIdFromName(applyToName);
            }
            else
            {
                Debug.WriteLine("Error: No category exists for the one selected. NewModifierDialogClass: AddModifierRecord()");
                return;
            }
            model.Name = NameTextBox.Text;
            model.Save();
            NewModifierId = model.Id;
        }
        private void CategoryComboBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            string category;

            category = CategoryComboBox.SelectedItem.ToString();

            ApplyToNames.Clear();
            if (category == "Ability")
            {
                ApplyToLabel.Text = "Select an Ability";
                ApplyToNames      = AbilityModel.GetNames();
            }
            else if (category == "Attribute")
            {
                ApplyToLabel.Text = "Select an Attribute";
                ApplyToNames      = AttributeModel.GetNames();
            }
            else if (category == "Feat")
            {
                ApplyToLabel.Text = "Select a Feat";
                ApplyToNames      = FeatModel.GetNames();
            }
            else if (category == "Save")
            {
                ApplyToLabel.Text = "Select a Save";
                ApplyToNames      = SaveModel.GetNames();
            }
            else if (category == "Skill")
            {
                ApplyToLabel.Text = "Select a Skill";
                ApplyToNames      = SkillModel.GetNames();
            }
            else if (category == "Spell")
            {
                ApplyToLabel.Text = "Select a spell";
                ApplyToNames      = SpellModel.GetNames();
            }
            else
            {
                Debug.WriteLine("Error: No category exists for the one selected. NewModifierDialogClass : CategoryComboBox_SelectedIndexChanged()");
                return;
            }
            FillApplyToComboBox();
            UpdateNameField();
        }