public async Task <IActionResult> Addstudent([FromServices] IUserStudentService studentService, [FromServices] IPhotoService photoService, string name, string surname, int day, int month, int year, int gender, string email, int number, string address, IFormFile image) { var user = await LoginUserHelperManager.GetCurrentUser(); IStudent student = new Student() { Address = address, Surname = surname, Gender = (Gender)gender, Mail = email, Name = name, Number = number, BirthDay = new DateTime(year, month, day), TeacherID = user.Key }; if (image != null) { student.Img = photoService.PhotoLink(image.FileName.Split('\\').LastOrDefault().Split('.').FirstOrDefault()); photoService.Upload(image.FileName); } else { student.Img = photoService.PhotoLink("person2_s1nfj5"); } await studentService.AddStudentAsync(student); return(RedirectToAction("StudentView")); }
public async Task <IActionResult> Grading([FromServices] IUserStudentService StudentService, [FromServices] IUserSubjectService SubjectService, string key, string info, int mark, int day, int month, int year, int gradingtype) { var Subject = await SubjectService.GetSubjectsAsync(); var students = await StudentService.GetStudentsAsync(); if (Subject.Count() != 0) { Subject .FirstOrDefault(o => o.Key == key) .Grades.ToList() .Add(new Grade() { Info = info, grading = (GradingType)gradingtype, Mark = mark, Time = new DateTime(year, month, day) }); } if (students.Count() != 0) { //var studentsdata = students.ToList(); //studentsdata // .FirstOrDefault(o => o.Key == key) // .Grades.ToList() // .Add(new Grade() // { // Info = info, // grading = (GradingType)gradingtype, // Mark = mark, // Time = new DateTime(year, month, day) // }); } return(RedirectToAction("Grading")); }
public async Task <IActionResult> StudentView([FromServices] IUserStudentService studentService) { var data = await studentService.GetStudentsAsync(); return(View(data)); }
public async Task <IActionResult> DeleteStudent([FromServices] IUserStudentService studentService, string key) { await studentService.DeleteStudentAsync(key); return(RedirectToAction("StudentView")); }