public static void StartProgram() { Console.Title = "My Classmates"; if (FileHandling.CheckFileFolderExistance() > 0) { Classmates.Populate(myClassmates); //Method for saving mockdata and user changes to a file. FileHandling.BinarySerializer(myClassmates); } // Else read the file else { myClassmates = FileHandling.BinaryDeSerializer(myClassmates); } Console.SetWindowSize(100, 40); FileHandling.CreateLogos(); //Runs the login method Login.UserLogin(); //If the program had to add any files, then populate that file with the standard classmates Menus.StartMenu(myClassmates); }
public void Calificar(Classmates notas) { Enroll matriculada = context.Enroll.Where(x => x.Course == notas.EnrollsNavigation.Course && x.Student == notas.EnrollsNavigation.Student).First(); Assign asignada = context.Assign.Where(x => x.Teacher == notas.AssignNavigation.Teacher && x.CourseId == notas.AssignNavigation.CourseId).First(); Classmates classmates = new Classmates() { Nota = notas.Nota, Enrolls = matriculada.Id, Assign = asignada.Id, Period = notas.Period, }; var datos = context.Classmates.Find(classmates.Assign, classmates.Enrolls, classmates.Period); if (datos != null) { datos.Nota = notas.Nota; context.Classmates.Update(datos); } else { context.Classmates.Add(classmates); } context.SaveChanges(); }
public ActionResult Calificar([FromBody] Classmates course) { try { new Academic().Calificar(course); return(Ok()); } catch (Exception) { return(NotFound()); } }
/*---------------------------------------------------------- * DIFFERENT MENUES * ----------------------------------------------------------*/ public static void StartMenu(List <Classmates> listOfClassmates) { do { Console.Clear(); FileHandling.LogoPrint("start"); PrintMenu(startMenu); Print.Blue(@"Ange ett alternativ \>"); int menuChoice; int.TryParse(Console.ReadLine(), out menuChoice); switch (menuChoice) { case 1: Menus.ListAllClassmates(listOfClassmates); break; case 2: Menus.ListDetailsClassmates(listOfClassmates, listBasicClassmatesMenu); break; case 3: RemoveMenu(listOfClassmates, listBasicClassmatesMenu); break; case 4: listOfClassmates.Clear(); Classmates.Populate(listOfClassmates); FileHandling.BinarySerializer(listOfClassmates); top = startMenu.Count + 11; left = 0; Console.SetCursorPosition(left, top); Print.Yellow("Mockdata återställd"); Thread.Sleep(1500); break; case 5: Environment.Exit(0); break; case 0: default: top = startMenu.Count + 11; left = 0; Console.SetCursorPosition(left, top); Print.Red("Felaktigt val, försök igen"); Thread.Sleep(1500); break; } } while (true); }