public long Add(ElectionOption electionOption) { if (DB.ElectionOptions.Any(c => c.ElectionOptionName == electionOption.ElectionOptionName && c.ElectionId == electionOption.ElectionId && c.DeleteRow == false)) { return(0); } DB.ElectionOptions.Add(electionOption); DB.SaveChanges(); return(DB.ElectionOptions.Where(c => c.ElectionOptionName == electionOption.ElectionOptionName && c.ElectionId == electionOption.ElectionId).Select(l => l.ElectionOptionId).ToList()[0]); }
public void Delete(long electionOptionId) { ElectionOption electionOption = DB.ElectionOptions.Where(e => e.ElectionOptionId == electionOptionId).ToList()[0]; if (electionOption != null) { electionOption.DeleteRow = true; DB.SaveChanges(); } }
//public long GetResult(List<ElectionOption> electionOptions) //{ // // List<ElectionResult> electionResults = new List<ElectionResult>(); // ElectionOption electionOption = new ElectionOption(); // int maxOption = 0,count; // long whichOption=0; // for (int i = 0; i < electionOptions.Count; i++) // { // electionOption = electionOptions[i]; // count = DB.ElectionResults.Count(r => r.ElectionOptionId == electionOption.ElectionOptionId); // if (count > maxOption) // { // maxOption = count; // whichOption = electionOption.ElectionOptionId; // } // } // return whichOption; //} public List <ElectionResult> GetResult(List <ElectionOption> electionOptions) { List <ElectionResult> electionResults = new List <ElectionResult>(); ElectionOption electionOption = new ElectionOption(); for (int i = 0; i < electionOptions.Count; i++) { electionOption = electionOptions[i]; electionResults.Add(DB.ElectionResults.Where(r => r.ElectionOptionId == electionOption.ElectionOptionId).ToList()[0]); } return(electionResults); }
public void Edit(ElectionOption electionOption) { DB.Entry(electionOption).State = EntityState.Modified; DB.SaveChanges(); }
public void Edit(ElectionOption electionOption) { ElectionOptionDal.Edit(electionOption); }
public long Add(ElectionOption electionOption) { return(ElectionOptionDal.Add(electionOption)); }
//הוספת אופציית בחירה public long AddOneElectionOption(ElectionOption electionOption) { return(ElectionOptionBL.Add(electionOption)); }