public static Election ToDataModel(ElectionViewModel election) { return(new Election { ElectionId = election.ElectionId, ElectionName = election.ElectionName, ElectionType = election.ElectionType, Country = election.Country, EndDate = election.EndDate, StartDate = election.StartDate, Dormant = election.Dormant, Candidates = election.Candidates.Select(x => CandidateViewModel.ToDataModel(x)).ToList() }); }
internal static Candidate ToDataModel(CandidateViewModel candidate) { return(new Candidate { CandidateName = candidate.CandidateName, Dormant = candidate.Dormant, AreaId = candidate.AreaId, CandidateId = candidate.CandidateId, PartyId = candidate.PartyId, Area = candidate.Area != null?AreaViewModel.ToDataModel(candidate.Area) : null, Party = candidate.Party != null?PartyViewModel.ToDataModel(candidate.Party) : null }); }
public static ElectionViewModel ToViewModel(Election election) { return(new ElectionViewModel { ElectionId = election.ElectionId, ElectionName = election.ElectionName, ElectionType = election.ElectionType, Country = election.Country, EndDate = election.EndDate, StartDate = election.StartDate, Dormant = election.Dormant, Candidates = election.Candidates != null?election.Candidates.Select(x => CandidateViewModel.ToViewModel(x, null)).ToList() : null }); }