Esempio n. 1
0
        public EntityType GetEntityType(string entityName)
        {
            TestEntityNameIsNull(entityName);

            try
            {
                return(EntityTypes.Where(entityType => entityType.Name.Equals(entityName)).First());
            }
            catch (Exception)
            {
                return(null);
            }
        }
 /// <summary>
 /// Adds a new entity type to the storage model.
 /// </summary>
 /// <param name="name">Entity type name from the new entitytype.</param>
 /// <returns>A new StoreEntityType object.</returns>
 public StoreEntityType AddEntityType(string name)
 {
     if (!EntityTypes.Where(et => et.Name.Equals(name, StringComparison.InvariantCultureIgnoreCase)).Any())
     {
         StoreEntityType et = new StoreEntityType(ParentFile, this, name);
         _storeEntityTypes.Add(name, et);
         et.NameChanged += new EventHandler <NameChangeArgs>(et_NameChanged);
         et.Removed     += new EventHandler(et_Removed);
         return(et);
     }
     else
     {
         throw new ArgumentException("An entity type with the name " + name + " already exist in the model.");
     }
 }
Esempio n. 3
0
        private void OnAddEntityType(string obj)
        {
            var selectedItems = Model.EntityTypeAssignments;
            var values        = EntityTypes.Where(x => selectedItems.All(y => y.EntityTypeName != x.Name))
                                .Select(x => new EntityTypeAssignment {
                EntityTypeName = x.Name, EntityTypeId = x.Id
            })
                                .ToList <IOrderable>();
            var selectedValues = InteractionService.UserIntraction.ChooseValuesFrom(
                values,
                selectedItems.ToList <IOrderable>(),
                Resources.EntityType.ToPlural(),
                string.Format(Resources.SelectItemsFor_f, Resources.EntityType.ToPlural(), Model.Name,
                              Resources.TicketType),
                Resources.EntityType,
                Resources.EntityType.ToPlural());

            Model.InjectFrom <EntityInjection>(new { EntityTypeAssignments = selectedValues.Cast <EntityTypeAssignment>().ToList() });
            _entityTypeAssignments = null;
            RaisePropertyChanged(() => EntityTypeAssignments);
        }