예제 #1
0
        /// <summary>Convert from LookupProperty DTO to entity</summary>
        /// <param name="dbContext">DB Context to use for attaching entity</param>
        /// <param name="dto">DTO to convert from</param>
        /// <param name="dtoEntities">Used internally to track which dtos have been converted to entites already (to avoid re-converting when circularly referenced)</param>
        /// <returns>Resultant LookupProperty entity</returns>
        public static LookupProperty FromDto(FACTS.Framework.DAL.DbContext dbContext, LookupPropertyDto dto, Dictionary <FACTS.Framework.Dto.BaseDto, BaseEntity> dtoEntities = null)
        {
            dtoEntities = dtoEntities ?? new Dictionary <FACTS.Framework.Dto.BaseDto, BaseEntity>();
            if (dtoEntities.ContainsKey(dto))
            {
                return((LookupProperty)dtoEntities[dto]);
            }

            LookupProperty entity = new LookupProperty();

            dtoEntities.Add(dto, entity);
            FromDtoSet(dbContext, dto, entity, dtoEntities);

            if (dbContext != null)
            {
                dbContext.Entry(entity).State = (dto.IsNew ? EntityState.Added : (dto.IsDeleted ? EntityState.Deleted : EntityState.Modified));
            }

            return(entity);
        }
예제 #2
0
        /// <summary>Convert from LookupProperty DTO to entity</summary>
        /// <param name="dbContext">DB Context to use for attaching entity</param>
        /// <param name="dto">DTO to convert from</param>
        /// <param name="dtoEntities">Used internally to track which dtos have been converted to entites already (to avoid re-converting when circularly referenced)</param>
        /// <returns>Resultant LookupProperty entity</returns>
        public static LookupProperty FromDto(FACTS.Framework.DAL.DbContext dbContext, LookupPropertyDto dto, Dictionary <FACTS.Framework.Dto.BaseDto, BaseEntity> dtoEntities = null)
        {
            dtoEntities = dtoEntities ?? new Dictionary <FACTS.Framework.Dto.BaseDto, BaseEntity>();
            if (dtoEntities.ContainsKey(dto))
            {
                return((LookupProperty)dtoEntities[dto]);
            }

            LookupProperty entity = new LookupProperty();

            dtoEntities.Add(dto, entity);

            entity.CreateDateTime = dto.CreateDateTime;
            entity.CreateUserId   = dto.CreateUserId;
            entity.DataType       = dto.DataType;
            entity.Description    = dto.Description;
            entity.Name           = dto.Name;
            entity.Property       = dto.Property;
            entity.UpdateDateTime = dto.UpdateDateTime;
            entity.UpdateNumber   = dto.UpdateNumber;
            entity.UpdateProcess  = dto.UpdateProcess;
            entity.UpdateUserId   = dto.UpdateUserId;

            entity.LookupName = (dto.LookupName == null) ? null : LookupName.FromDto(dbContext, dto.LookupName, dtoEntities);
            if (dto.LookupValues != null)
            {
                foreach (LookupValueDto lookupValue in dto.LookupValues)
                {
                    entity.LookupValues.Add(DbEntities.LookupValue.FromDto(dbContext, lookupValue, dtoEntities));
                }
            }

            if (dbContext != null)
            {
                dbContext.Entry(entity).State = (dto.IsNew ? EntityState.Added : (dto.IsDeleted ? EntityState.Deleted : EntityState.Modified));
            }

            return(entity);
        }
예제 #3
0
        protected static void FromDtoSet(FACTS.Framework.DAL.DbContext dbContext, LookupPropertyDto dto, LookupProperty entity, Dictionary <FACTS.Framework.Dto.BaseDto, BaseEntity> dtoEntities)
        {
            entity.CreateDateTime = dto.CreateDateTime;
            entity.CreateUserId   = dto.CreateUserId;
            entity.DataType       = dto.DataType;
            entity.Description    = dto.Description;
            entity.Name           = dto.Name;
            entity.Property       = dto.Property;
            entity.UpdateDateTime = dto.UpdateDateTime;
            entity.UpdateNumber   = dto.UpdateNumber;
            entity.UpdateProcess  = dto.UpdateProcess;
            entity.UpdateUserId   = dto.UpdateUserId;

            entity.LookupName = (dto.LookupName == null) ? null : LookupName.FromDto(dbContext, dto.LookupName, dtoEntities);
            if (dto.LookupValues != null)
            {
                foreach (LookupValueDto lookupValue in dto.LookupValues)
                {
                    entity.LookupValues.Add(DbEntities.LookupValue.FromDto(dbContext, lookupValue, dtoEntities));
                }
            }
        }