public IncidentReviewDataDTO MapToReviewDataDTO(IncidentReviewEntity source, IncidentReviewDataDTO target = null) { if (source == null) { return(null); } if (target == null) { target = new IncidentReviewDataDTO(); } MapToReviewInfoDTO(source, target); //target.Author = MapToMemberInfoDTO(source.Author); target.IncidentKind = source.IncidentKind; target.FullDescription = source.FullDescription; target.AuthorName = source.AuthorName; target.Comments = source.Comments.Select(x => MapToReviewCommentDataDTO(x)).ToList(); target.Corner = source.Corner; target.InvolvedMembers = source.InvolvedMembers.Select(x => MapToMemberInfoDTO(x)).ToList(); target.OnLap = source.OnLap; target.ReviewId = source.ReviewId; target.Session = MapToSessionInfoDTO(source.Session); target.TimeStamp = source.TimeStamp; target.AcceptedReviewVotes = source.AcceptedReviewVotes.Select(x => MapToReviewVoteDataDTO(x)).ToArray(); return(target); }
public IncidentReviewEntity MapToReviewEntity(IncidentReviewDataDTO source, IncidentReviewEntity target = null) { if (source == null) { return(null); } if (target == null) { target = GetReviewEntity(source); } if (!MapToRevision(source, target)) { return(target); } //target.Author = GetMemberEntity(source.Author); target.AuthorUserId = source.AuthorUserId; target.Session = GetSessionBaseEntity(new SessionInfoDTO() { SessionId = source.SessionId }); target.IncidentKind = source.IncidentKind; target.FullDescription = source.FullDescription; target.AuthorName = source.AuthorName; if (target.Comments == null) { target.Comments = new List <ReviewCommentEntity>(); } MapCollection(source.Comments, target.Comments, MapToReviewCommentEntity, x => x.CommentId); target.Corner = source.Corner; if (target.InvolvedMembers == null) { target.InvolvedMembers = new List <Entities.Members.LeagueMemberEntity>(); } MapCollection(source.InvolvedMemberIds.Select(x => new LeagueMemberInfoDTO() { MemberId = x }), target.InvolvedMembers, GetMemberEntity, x => x.MemberId, removeFromCollection: true); target.OnLap = source.OnLap; target.TimeStamp = source.TimeStamp; if (target.AcceptedReviewVotes == null) { target.AcceptedReviewVotes = new List <AcceptedReviewVoteEntity>(); } MapCollection(source.AcceptedReviewVotes, target.AcceptedReviewVotes, MapToAcceptedReviewVoteEntity, x => x.ReviewVoteId, removeFromCollection: true, removeFromDatabase: true, autoAddMissing: true); target.ResultLongText = source.ResultLongText; target.IncidentNr = source.IncidentNr; if (target.Session?.SessionResult != null) { target.Session.SessionResult.RequiresRecalculation = true; } return(target); }
public IncidentReviewInfoDTO MapToReviewInfoDTO(IncidentReviewEntity source, IncidentReviewInfoDTO target = null) { if (source == null) { return(null); } if (target == null) { target = new IncidentReviewInfoDTO(); } MapToVersionInfoDTO(source, target); target.ReviewId = source.ReviewId; target.AuthorName = source.AuthorName; target.AuthorUserId = source.AuthorUserId; return(target); }
public IncidentReviewEntity MapToReviewEntity(IncidentReviewDataDTO source, IncidentReviewEntity target = null) { if (source == null) { return(null); } if (target == null) { target = GetReviewEntity(source); } if (!MapToRevision(source, target)) { return(target); } //target.Author = GetMemberEntity(source.Author); target.AuthorUserId = source.AuthorUserId; target.Session = GetSessionBaseEntity(source.Session); target.IncidentKind = source.IncidentKind; target.FullDescription = source.FullDescription; target.AuthorName = source.AuthorName; if (target.Comments == null) { target.Comments = new List <ReviewCommentEntity>(); } MapCollection(source.Comments, target.Comments, MapToReviewCommentEntity, x => x.CommentId); target.Corner = source.Corner; if (target.InvolvedMembers == null) { target.InvolvedMembers = new List <Entities.Members.LeagueMemberEntity>(); } MapCollection(source.InvolvedMembers, target.InvolvedMembers, GetMemberEntity, x => x.MemberId, removeFromCollection: true); target.OnLap = source.OnLap; target.TimeStamp = source.TimeStamp; if (target.AcceptedReviewVotes == null) { target.AcceptedReviewVotes = new List <AcceptedReviewVoteEntity>(); } MapCollection(source.AcceptedReviewVotes, target.AcceptedReviewVotes, MapToAcceptedReviewVoteEntity, x => x.ReviewVoteId, removeFromCollection: true, removeFromDatabase: true); return(target); }