Advertisement
mhorvat2

Untitled

Jan 21st, 2018
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.40 KB | None | 0 0
  1. //ElectionRepository
  2.         public CandidatureStatusEnum GetCandidatureStatus(Candidature candidature)
  3.         {
  4.             return candidaturestatusesSet.First(t => t.Id == candidature.CandidatureStatusId).Status;
  5.         }
  6.  
  7.         public void SetStatus(Candidature candidature)
  8.         {
  9.             candidaturesSet.First(t => t.Id == candidature.Id).CandidatureStatusId = candidature.CandidatureStatusId;
  10.  
  11.             context.SaveChanges();
  12.         }
  13.  
  14.        public List<Candidature> GetElectionResults(Election election)
  15.         {
  16.             List<Candidature> list = new List<Candidature>();
  17.  
  18.             list = candidaturesSet.Where(t => t.ElectionId == election.Id & t.CandidatureStatusId == 2).ToList();
  19.  
  20.             List<Candidature> sortedList = list.OrderByDescending(o => o.NumberOfVotes).ToList();
  21.  
  22.             return sortedList;
  23.         }
  24. //PersonRepository
  25.         public void AddPerson(Person person)
  26.         {
  27.             context.Entry(person).State = EntityState.Added;
  28.  
  29.             context.SaveChanges();
  30.         }
  31.  
  32.         public void MakeActive(Person person)
  33.         {
  34.             personsSet.First(t => t.Id == person.Id).IsActive = true;
  35.  
  36.             context.SaveChanges();
  37.         }
  38. //Team Repository
  39.         public void DeleteTeam(Team team)
  40.         {
  41.             context.Entry(team).State = EntityState.Deleted;
  42.  
  43.             context.SaveChanges();
  44.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement