Exemplo n.º 1
0
        public ExternalApplicationKey createExternalApplicationKey(
            EntityType entityType,
            string externalId,
            int externalSystemId,
            int internalId,
            EntityAction action = EntityAction.InsertOnSubmit
            )
        {
            var entity = Factory.CreateExternalApplicationKey(entityType, externalId, externalSystemId, internalId);

            DbAction(entity, action);

            return(entity);
        }
Exemplo n.º 2
0
 public static ExternalApplicationKey CreateExternalApplicationKey(
     EntityType entityType,
     string externalId,
     int externalSystemId,
     int internalId
     )
 {
     return(new ExternalApplicationKey
     {
         EntityType = Enum.GetName(typeof(EntityType), entityType),
         ExternalId = externalId,
         SystemId = externalSystemId,
         InternalId = internalId,
         Added = DateTime.Now
     });
 }
Exemplo n.º 3
0
        public static void DeleteWithKeys <T>(RSMDataModelDataContext context, EntityType type, string extId, int sysId) where T : class, IEntity
        {
            if (context == null)
            {
                return;
            }

            var keys = DeleteKeys(context, type, sysId, extId);

            if (keys == null)
            {
                return;
            }

            //TODO: clean this up once People, Location are refactored to conform to IEntity
            if (type == EntityType.Person)
            {
                var entity = context.Persons.FirstOrDefault(x => x.PersonID.Equals(keys.InternalId));
                if (entity != null)
                {
                    context.Persons.DeleteOnSubmit(entity);
                }
            }
            else if (type == EntityType.Location)
            {
                var entity = context.Locations.FirstOrDefault(x => x.LocationID.Equals(keys.InternalId));
                if (entity != null)
                {
                    context.Locations.DeleteOnSubmit(entity);
                }
            }
            else
            {
                var eTable = context.GetTable <T>();
                var entity = eTable.FirstOrDefault(x => x.Id.Equals(keys.InternalId));
                if (entity != null)
                {
                    eTable.DeleteOnSubmit(entity);
                }
            }
        }
Exemplo n.º 4
0
        public static ExternalApplicationKey DeleteKeys(RSMDataModelDataContext context, EntityType type, int sysId, string extId = null, int?Id = null)
        {
            if (context == null)
            {
                return(null);
            }
            if (extId == null && Id == null)
            {
                return(null);
            }

            var entityType = Enum.GetName(typeof(EntityType), type);
            var keys       = context.ExternalApplicationKeys.FirstOrDefault(x => x.SystemId == sysId && x.EntityType == entityType &&
                                                                            ((extId != null && x.ExternalId == extId) || (Id != null && x.InternalId == Id)));

            if (keys == null)
            {
                return(null);
            }

            context.ExternalApplicationKeys.DeleteOnSubmit(keys);
            return(keys);
        }