public PerformerView(Performer performer) { AutoMapper.Mapper.CreateMap<Performer, PerformerView>(); AutoMapper.Mapper.Map<Performer, PerformerView>(performer, this); this.assignmentIds = performer.assignments.Select(p => p.id); this.timeReportIds = performer.timeReports.Select(a => a.id); this.birthDate = performer.birthDate.ToString().Replace('T', ' '); this.startDate = performer.startDate.ToString().Replace('T', ' '); this.updated = performer.updated.ToString().Replace('T', ' '); this.created = performer.created.ToString().Replace('T', ' '); }
public Performer convert(EntityFrameworkContext context) { var performer = new Performer(); AutoMapper.Mapper.CreateMap<PerformerView, Performer>(); AutoMapper.Mapper.Map<PerformerView, Performer>(this, performer); if (this.assignmentIds != null) foreach (var assignment in context.assignments.Where(a => this.assignmentIds.Contains(a.id))) performer.assignments.Add(assignment); if (this.timeReportIds != null) foreach (var assignmentTimeReport in context.performerTimeReports.Where(a => this.timeReportIds.Contains(a.id))) performer.timeReports.Add(assignmentTimeReport); return performer; }