public WorkDto(WorkEntity entity, List <WorkEntity> nextWorks, List <WorkEntity> prevWorks) { if (entity == null) { return; } Id = entity.Id; JobName = entity.JobName; PlannedStartDate = entity.PlannedStartDate; FactStartDate = entity.FactStartDate; IncDayCost = entity.IncDayCost; DecDayCost = entity.DecDayCost; NormDuration = entity.NormDuration; MinimalDuration = entity.MinimalDuration; MinimalDurationCost = entity.MinimalDurationCost; AddedCost = entity.AddedCost; AddedChildrenCost = entity.AddedChildrenCost; NewPlannedStartDate = entity.NewPlannedStartDate; HasChildren = entity.PrevWorks.Any(); if (nextWorks != null) { NextWorks.AddRange(nextWorks.Select(s => new WorkDto(s))); } if (prevWorks != null) { PrevWorks.AddRange(prevWorks.Select(s => new WorkDto(s))); } }
public WorkDto(WorkEntity entity) : base(entity) { if (entity == null) { return; } PlannedStartDate = entity.PlannedStartDate; FactStartDate = entity.FactStartDate; IncDayCost = entity.IncDayCost; DecDayCost = entity.DecDayCost; NormDuration = entity.NormDuration; MinimalDuration = entity.MinimalDuration; MinimalDurationCost = entity.MinimalDurationCost; AddedCost = entity.AddedCost; AddedChildrenCost = entity.AddedChildrenCost; NewPlannedStartDate = entity.NewPlannedStartDate; if (entity.NextWorks.Any()) { entity.NextWorks.ForEach(e => NextWorks.Add(new WorkDto(e.NextWork))); } if (entity.PrevWorks.Any()) { entity.PrevWorks.ForEach(e => PrevWorks.Add(new WorkDto(e.PrevWork))); } }