예제 #1
0
 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()
     });
 }
예제 #2
0
        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
            });
        }
예제 #3
0
 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
     });
 }