예제 #1
0
 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]);
 }
예제 #2
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();
            }
        }
예제 #3
0
        //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);
        }
예제 #4
0
 public void Edit(ElectionOption electionOption)
 {
     DB.Entry(electionOption).State = EntityState.Modified;
     DB.SaveChanges();
 }
예제 #5
0
 public void Edit(ElectionOption electionOption)
 {
     ElectionOptionDal.Edit(electionOption);
 }
예제 #6
0
 public long Add(ElectionOption electionOption)
 {
     return(ElectionOptionDal.Add(electionOption));
 }
예제 #7
0
 //הוספת אופציית בחירה
 public long AddOneElectionOption(ElectionOption electionOption)
 {
     return(ElectionOptionBL.Add(electionOption));
 }