/// <summary>Convert from VoluntaryPlanWaiverRequest 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 VoluntaryPlanWaiverRequest entity</returns> public static VoluntaryPlanWaiverRequest FromDto(FACTS.Framework.DAL.DbContext dbContext, VoluntaryPlanWaiverRequestDto dto, Dictionary <FACTS.Framework.Dto.BaseDto, BaseEntity> dtoEntities = null) { dtoEntities = dtoEntities ?? new Dictionary <FACTS.Framework.Dto.BaseDto, BaseEntity>(); if (dtoEntities.ContainsKey(dto)) { return((VoluntaryPlanWaiverRequest)dtoEntities[dto]); } VoluntaryPlanWaiverRequest entity = new VoluntaryPlanWaiverRequest(); dtoEntities.Add(dto, entity); entity.CreateDateTime = dto.CreateDateTime; entity.CreateUserId = dto.CreateUserId; entity.EmployerId = dto.EmployerId; entity.EndDate = dto.EndDate; entity.FormId = dto.FormId; entity.IsVoluntaryPlanWaiverRequestAcknowledged = dto.IsVoluntaryPlanWaiverRequestAcknowledged; entity.StartDate = dto.StartDate; entity.UpdateDateTime = dto.UpdateDateTime; entity.UpdateNumber = dto.UpdateNumber; entity.UpdateProcess = dto.UpdateProcess; entity.UpdateUserId = dto.UpdateUserId; entity.VoluntaryPlanWaiverRequestId = dto.VoluntaryPlanWaiverRequestId; entity.Employer = (dto.Employer == null) ? null : Employer.FromDto(dbContext, dto.Employer, dtoEntities); entity.Form = (dto.Form == null) ? null : Form.FromDto(dbContext, dto.Form, dtoEntities); if (dto.VoluntaryPlanWaiverRequestTypes != null) { foreach (VoluntaryPlanWaiverRequestTypeDto voluntaryPlanWaiverRequestType in dto.VoluntaryPlanWaiverRequestTypes) { entity.VoluntaryPlanWaiverRequestTypes.Add(DbEntities.VoluntaryPlanWaiverRequestType.FromDto(dbContext, voluntaryPlanWaiverRequestType, dtoEntities)); } } if (dbContext != null) { dbContext.Entry(entity).State = (dto.IsNew ? EntityState.Added : (dto.IsDeleted ? EntityState.Deleted : EntityState.Modified)); } return(entity); }
/// <summary>Convert from VoluntaryPlanWaiverRequest 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 VoluntaryPlanWaiverRequest entity</returns> public static VoluntaryPlanWaiverRequest FromDto(FACTS.Framework.DAL.DbContext dbContext, VoluntaryPlanWaiverRequestDto dto, Dictionary <FACTS.Framework.Dto.BaseDto, BaseEntity> dtoEntities = null) { dtoEntities = dtoEntities ?? new Dictionary <FACTS.Framework.Dto.BaseDto, BaseEntity>(); if (dtoEntities.ContainsKey(dto)) { return((VoluntaryPlanWaiverRequest)dtoEntities[dto]); } VoluntaryPlanWaiverRequest entity = new VoluntaryPlanWaiverRequest(); dtoEntities.Add(dto, entity); Form.FromDtoSet(dbContext, dto, entity, dtoEntities); FromDtoSet(dbContext, dto, entity, dtoEntities); if (dbContext != null) { dbContext.Entry(entity).State = (dto.IsNew ? EntityState.Added : (dto.IsDeleted ? EntityState.Deleted : EntityState.Modified)); } return(entity); }
protected static void FromDtoSet(FACTS.Framework.DAL.DbContext dbContext, VoluntaryPlanWaiverRequestDto dto, VoluntaryPlanWaiverRequest entity, Dictionary <FACTS.Framework.Dto.BaseDto, BaseEntity> dtoEntities) { entity.EmployerId = dto.EmployerId; entity.EndDate = dto.EndDate; entity.IsVoluntaryPlanWaiverRequestAcknowledged = dto.IsVoluntaryPlanWaiverRequestAcknowledged; entity.StartDate = dto.StartDate; entity.Employer = (dto.Employer == null) ? null : Employer.FromDto(dbContext, dto.Employer, dtoEntities); if (dto.VoluntaryPlanWaiverRequestTypes != null) { foreach (VoluntaryPlanWaiverRequestTypeDto voluntaryPlanWaiverRequestType in dto.VoluntaryPlanWaiverRequestTypes) { entity.VoluntaryPlanWaiverRequestTypes.Add(DbEntities.VoluntaryPlanWaiverRequestType.FromDto(dbContext, voluntaryPlanWaiverRequestType, dtoEntities)); } } }