Пример #1
0
        public static int WriteInDatabase(List <StudentSubject> StudSubj, int z, Mid_Exam7 db)
        {
            int k = 0;

            if (StudSubj.Count > 0)
            {
                for (int j = 0; j < StudSubj.Count; j++)
                {
                    for (int i = 0; i < z; i++)
                    {
                        if (StudSubj[j].StudentId == db.StudentSubjects.ToArray()[i].StudentId && StudSubj[j].SubjectId == db.StudentSubjects.ToArray()[i].SubjectId)
                        {
                            //Qulis Chawera
                            db.StudentSubjects.ToArray()[i].Grade = StudSubj[j].Grade;
                            db.SaveChanges();

                            //Warmatebit Daimportebuli Qulebi
                            Console.WriteLine("Warmatebit Daimportda Shemdegi Monacemi:StudentId - " + StudSubj[j].StudentId
                                              + " ,SubjectId - " + StudSubj[j].SubjectId + " ,Grade - " + StudSubj[j].Grade);
                            //StudSubj.Remove - s viyeneb imitom, rom vinaidan da radganac swori monacemebi ukve chaiwera
                            //mashin List-dan da ara bazidan, misi washlit mxolod araswori monacemebi gvrcheba, rac gvimartivebs sakitxs!
                            StudSubj.Remove(StudSubj[j]);
                            //Warmatebit Daimportebuli Chanawerebis Gazrda
                            k++;
                        }
                    }
                }
            }
            else
            {
                throw new System.ArgumentOutOfRangeException("Size Of List", StudSubj.Count, ListSize1);
            }
            return(k);
        }
Пример #2
0
 public static void Main(string[] args)
 {
     using (Mid_Exam7 db = new Mid_Exam7())
     {
         Console.WriteLine("Subject Cxrilshi Chaiwera 5 Saganis Saxeli!");
         Console.WriteLine("Students Cxrilshi Chaiwera 50 Studentis Saxeli!");
         Console.WriteLine("StudentSubjects Cxrilshi Chaiwera 100 Monacemi");
         string[] m1 = new string[] { };
         int      v  = File.ReadAllLines("C:/Users/Nikusha/Desktop/EntityFrameworkCoreDemo-master/EntityFrameworkCore/Grades.csv").Length;
         //Failis Kitxva
         m1 = ReadFile(m1, v);
         //StudentsSubject Cxrilis Length-is Minicheba, Romelsac Amave Kodshi Viyenebt
         int z = db.StudentSubjects.ToArray().Length;
         //Listis Sheqmna
         List <StudentSubject> StudSubj = new List <StudentSubject>();
         //Listis Shevseba
         StudSubj = FillList(StudSubj, m1);
         //i1 Warmoadgens Warmatebit Chaweril Monacemta Raodenobis Aghmnishvnels.Tavidan Is Nulia!
         //WriteInDatabase Metodis Gamotenebit ki Bazashi Vwer Grade-is Shesabamis Mnishvnelobebs!
         int i1 = WriteInDatabase(StudSubj, z, db);
         //Warmatebulad Daimportebulebis Raodenoba
         Console.WriteLine("StudentSubject Bazashi Chaiwera " + i1 + " Cali Qula!");
         //Warumateblad Daimportebulebi
         for (int i = 0; i < StudSubj.Count; i++)
         {
             Console.WriteLine("Warumateblad Daimportda Shemdegi Monacemi: StudentId - " + StudSubj[i].StudentId
                               + " ,SubjectId - " + StudSubj[i].SubjectId + " ,Grade - " + StudSubj[i].Grade);
         }
         //Warumateblad Daimportebulebis Raodenoba
         int z1 = m1.Length - 1 - i1;
         Console.WriteLine("StudentSubject Bazashi Ver Chaiwera " + z1 + " Cali Qula");
         //Ucvlelta Raodenoba
         int z2 = z - i1;
         Console.WriteLine("Bazashi Ucvleli Darcha " + z2 + " Monacemi!");
     }
 }