Esempio n. 1
0
        /// <summary>
        /// Sets properties on an instance of 'LookupValue'.
        /// </summary>
        public static void SetProperties(int lookupId, string[] propertyNames, object[] propertyValues)
        {
            LookupValue entity = BootFX.Common.Data.LookupValue.GetById(lookupId);

            entity.SetProperties(entity, propertyNames, propertyValues);
            entity.SaveChanges();
        }
Esempio n. 2
0
        /// <summary>
        /// Gets the <see cref="LookupValue"/> entity where the ID matches the given specification.
        /// </summary>
        public static LookupValue GetById(int lookupId, BootFX.Common.Data.SqlOperator lookupIdOperator, BootFX.Common.OnNotFound onNotFound)
        {
            BootFX.Common.Data.SqlFilter filter = new BootFX.Common.Data.SqlFilter(typeof(LookupValue));
            filter.Constraints.Add("LookupId", lookupIdOperator, lookupId);
            LookupValue results = ((LookupValue)(filter.ExecuteEntity()));

            return(results);
        }
Esempio n. 3
0
        /// <summary>
        /// Creates and instance of 'LookupValue'.
        /// </summary>
        public static LookupValue CreateInstance(string name, int value)
        {
            LookupValue entity = new LookupValue();

            entity.Name  = name;
            entity.Value = value;
            entity.SaveChanges();
            return(entity);
        }
Esempio n. 4
0
        public static LookupValue CreateAndSave(string name, string description)
        {
            if (name == null)
            {
                throw new ArgumentNullException("name");
            }
            if (name.Length == 0)
            {
                throw new ArgumentOutOfRangeException("'name' is zero-length.");
            }
            if (description == null)
            {
                throw new ArgumentNullException("description");
            }
            if (description.Length == 0)
            {
                throw new ArgumentOutOfRangeException("'description' is zero-length.");
            }

            // has it already been used...
            if (Contains(name, description))
            {
                throw new InvalidOperationException(string.Format("Lookup '{0}' already contains '{1}'.", name, description));
            }

            // get...
            LookupValue item = new LookupValue();

            item.Name        = name;
            item.Description = description;
            item.Value       = GetNextValueForLookup(name);

            // save...
            item.SaveChanges();

            // return...
            return(item);
        }
Esempio n. 5
0
 /// <summary>
 /// Adds a <see cref="LookupValue"/> instance to the collection.
 /// </summary>
 public int Add(LookupValue item)
 {
     return(base.Add(item));
 }