public async Task <StudentDetailsVM> StudentById(int id) { StudentDetailsVM obj = new StudentDetailsVM(); using (SqlConnection sqlConnection = new SqlConnection(connection)) { sqlConnection.Open(); SqlCommand sqlCommand = new SqlCommand(); sqlCommand.Connection = sqlConnection; sqlCommand.CommandType = CommandType.StoredProcedure; sqlCommand.CommandText = "GetStudentById"; sqlCommand.Parameters.AddWithValue("@StudentId", id); using (SqlDataReader sqlDataReader = await sqlCommand.ExecuteReaderAsync()) { while (sqlDataReader.Read()) { obj.StudentId = (int)(sqlDataReader["StudentId"] == DBNull.Value ? null : sqlDataReader["StudentId"]); obj.StudentName = (string)(sqlDataReader["StudentName"] == DBNull.Value ? null : sqlDataReader["StudentName"]); obj.Class = (string)(sqlDataReader["Class"] == DBNull.Value ? null : sqlDataReader["Class"]); obj.Divistion = (string)(sqlDataReader["Division"] == DBNull.Value ? null : sqlDataReader["Division"]); } sqlDataReader.Close(); } sqlConnection.Close(); } return(obj); }
public async Task <ResponseVM> SaveStudent(StudentDetailsVM model) { ResponseVM obj = new ResponseVM(); using (SqlConnection sqlConnection = new SqlConnection(connection)) { try { sqlConnection.Open(); SqlCommand sqlCommand = new SqlCommand(); sqlCommand.Connection = sqlConnection; sqlCommand.CommandType = CommandType.StoredProcedure; sqlCommand.CommandText = "SaveStudent"; sqlCommand.Parameters.Add("@ResCode", SqlDbType.VarChar, 30); sqlCommand.Parameters["@ResCode"].Direction = ParameterDirection.Output; sqlCommand.Parameters.Add("@ResMessage", SqlDbType.VarChar, 30); sqlCommand.Parameters["@ResMessage"].Direction = ParameterDirection.Output; sqlCommand.Parameters.AddWithValue("@StudentId", model.StudentId); sqlCommand.Parameters.AddWithValue("@StudentName", model.StudentName); sqlCommand.Parameters.AddWithValue("@Class", model.Class); sqlCommand.Parameters.AddWithValue("@Division", model.Divistion); await sqlCommand.ExecuteNonQueryAsync(); obj.ResCode = Convert.ToInt32(sqlCommand.Parameters["@ResCode"].Value); obj.ResMessage = (string)sqlCommand.Parameters["@ResMessage"].Value; sqlConnection.Close(); } catch (Exception ex) { } } return(obj); }
public ActionResult Edit(StudentDetailsVM StudentVM, HttpPostedFileBase uploadimage) { string path = Path.Combine(Server.MapPath("~/Images"), uploadimage.FileName); uploadimage.SaveAs(path); //InstructorBL instructorBL; Student std = new Student(); std.StudentID = StudentVM.StudentID; std.CountryID = StudentVM.CountryID; std.FullName = StudentVM.FullName; std.Picture = StudentVM.Picture; std.Picture = uploadimage.FileName; if (ModelState.IsValid) { //instructorBL = new InstructorBL(); bool chk = studentBL.UpdateStudent(std); if (chk) { return(RedirectToAction("Edit")); } else { return(View(StudentVM)); } } else { return(View(StudentVM)); } }
public async Task <IEnumerable <StudentDetailsVM> > StudentList() { List <StudentDetailsVM> _studentLst = new List <StudentDetailsVM>(); using (SqlConnection sqlConnection = new SqlConnection(connection)) { sqlConnection.Open(); SqlCommand sqlCommand = new SqlCommand(); sqlCommand.Connection = sqlConnection; sqlCommand.CommandType = CommandType.StoredProcedure; sqlCommand.CommandText = "GetAllStudent"; using (SqlDataReader sqlDataReader = await sqlCommand.ExecuteReaderAsync()) { while (sqlDataReader.Read()) { StudentDetailsVM obj = new StudentDetailsVM() { StudentId = (int)(sqlDataReader["StudentId"] == DBNull.Value ? null : sqlDataReader["StudentId"]), StudentName = (string)(sqlDataReader["StudentName"] == DBNull.Value ? null : sqlDataReader["StudentName"]), Class = (string)(sqlDataReader["Class"] == DBNull.Value ? null : sqlDataReader["Class"]), Divistion = (string)(sqlDataReader["Division"] == DBNull.Value ? null : sqlDataReader["Division"]) }; _studentLst.Add(obj); } sqlDataReader.Close(); } sqlConnection.Close(); } return(_studentLst); }
public ActionResult Create(StudentDetailsVM mod) { try { if (!ModelState.IsValid) { return(View(mod)); } var Student = _mapper.Map <Student>(mod); // Student.DOB= DateTime.Now; var isSuccess = _repo.Create(Student); if (!isSuccess) { ModelState.AddModelError("", "There might be an error!"); return(View(mod)); } return(RedirectToAction(nameof(Index))); } catch { ModelState.AddModelError("", "There might be an error!"); return(View(mod)); } }
public ActionResult Details(int id) { StudentDetailsVM vm = new StudentDetailsVM(); var student = dbContext.Students .Include(s => s.College) .Where(s => s.Id == id).First(); vm.EditImagePath = student.DisplayImage; vm.Name = student.Name; vm.College = student.College; vm.Roll_no = student.Roll_no; return(View(vm)); }
public async Task <IActionResult> StudentDetailsByAccountant(Int64 StudentId) { try { var result = new StudentDetails() { StudentId = StudentId }; var studentList = await Task.Run(() => _studentsServ.StudentDetails(result)); var temp = new StudentDetailsVM_Students() { Id = studentList.student.Id, ClassId = studentList.student.ClassId, CurrentClassName = studentList.student.CurrentClassName, ClassName = studentList.student.ClassName, GenderId = studentList.student.GenderId, GenderName = studentList.student.GenderName, RegistrationNo = studentList.student.RegistrationNo, FirstName = studentList.student.FirstName, LastName = studentList.student.LastName, StudentName = studentList.student.StudentName, FatherName = studentList.student.FatherName, MotherName = studentList.student.MotherName, ParentsName = studentList.student.ParentsName, IP300X200 = studentList.student.IP300X200, AdmittedYear = studentList.student.AdmittedYear, PresentAddress = studentList.student.PresentAddress, PermanentAddress = studentList.student.PermanentAddress, DOB = studentList.student.DOB, IsActive = studentList.student.IsActive, AddedBy = studentList.student.AddedBy = 0, AddedDate = DateTime.Now, ModifiedBy = 0, ModifiedDate = DateTime.Now, DataType = null }; var model = new StudentDetailsVM() { Students = temp }; return(View("StudentDetailsByAccountant", model)); } catch { return(BadRequest()); } }
public ActionResult Edit(int id) { StudentDetailsVM model = new StudentDetailsVM(); model.countries = studentBL.GetAllCountries(); Student std = studentBL.GetStudentByID(id); model.CountryID = std.CountryID; model.FullName = std.FullName; model.StudentID = std.StudentID; model.Picture = std.Picture; model.RegisterationDate = std.RegisterationDate; return(View(model)); }
// GET: Student/Details/5 public ActionResult Details(int?id) { SchoolContext db = new SchoolContext(); if (Session["UserId"] == null) { TempData["ErrorMessage"] = " Vous n'êtes pas autorisés à accéder à la section Détail. Veuillez vous loggez."; return(RedirectToAction("Index")); } if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Student student = db.Students.Include(s => s.FileImage).SingleOrDefault(s => s.ID == id); if (student == null) { return(HttpNotFound()); } StudentDetailsVM model = new StudentDetailsVM(); List <Course> CourseEnrolled = new List <Course>(); foreach (Enrollment enrollment in student.Enrollments) { CourseEnrolled.Add(db.Courses.FirstOrDefault(c => c.CourseID == enrollment.CourseID)); } List <int> CourseEnrolledID = CourseEnrolled.Select(c => c.CourseID).ToList(); var temp = db.Courses.Where(c => !CourseEnrolledID.Contains(c.CourseID)); List <Course> CoursesNotEnrolled = temp.ToList(); List <EnrollmentVM> NotEnrolled = new List <EnrollmentVM>(); model.EnrollmentDate = student.EnrollmentDate; model.Enrollments = student.Enrollments; model.Student = student; model.StudentID = student.ID; model.CoursesList = CoursesNotEnrolled; model.FileImage = student.FileImage; return(View(model)); }
public IActionResult Details(int id) { var student = _repo.ReadStudent(id); if (student != null) { var model = new StudentDetailsVM { Id = student.Id, Name = student.Name, Interest = student.Interest, Professionals = student.Professionals }; return(View(model)); } return(RedirectToAction("Index", "Home")); }
public ActionResult StudentDetails(int studentId) { Student student = studentServices.GetStudent(studentId); if (student == null) { return(NotFound()); } StudentDetailsVM studentDetails = new StudentDetailsVM { Id = student.Id, FirstName = student.FirstName, LastName = student.LastName, Email = student.Email }; return(View(studentDetails)); }
public ActionResult Details(StudentDetailsVM enrollmentVM) { SchoolContext db = new SchoolContext(); if (Session["UserID"] == null) { return(View()); } int id = int.Parse(Session["UserId"].ToString()); Enrollment enrollment = new Enrollment { StudentID = enrollmentVM.StudentID, CourseID = enrollmentVM.CourseID }; db.Enrollments.Add(enrollment); db.SaveChanges(); ViewBag.Message = "Subscription successful !"; return(RedirectToAction("Details", new { id = enrollment.StudentID })); }
public ActionResult Delete(int id, StudentDetailsVM mod) { try { var student = _repo.FindById(id); if (student == null) { return(NotFound()); } var isSuccess = _repo.Delete(student); if (!isSuccess) { return(View(mod)); } return(RedirectToAction(nameof(Index))); } catch { return(View()); } }
public async Task <ResponseVM> StudentSave([FromBody] StudentDetailsVM model) { return(await repo?.SaveStudent(model)); }
public ActionResult Details(int?id, StudentDetailsVM model, string submitBtn) { if (!id.HasValue) { return(RedirectToAction("ManageStudents", "Admin")); } Student student = unitOfWork.StudentRepository.GetById(id.Value); if (student == null) { return(RedirectToAction("ManageStudents", "Admin")); } model.Id = student.Id; model.FirstName = student.FirstName; model.LastName = student.LastName; model.Username = student.Username; model.IsConfirmed = student.IsConfirmed; model.IsActive = student.IsActive; model.Email = student.Email; model.FacultyNumber = student.FacultyNumber; if (student.CourseId != null) { model.CoursesSubjects = unitOfWork.CoursesSubjectsRepository.GetStudentsDetails(student.CourseId.Value, student.Id, unitOfWork); model.Course = unitOfWork.CourseRepository.GetById(student.CourseId.Value); } model.Props = new Dictionary <string, object>(); switch (model.SortOrder) { case "subject_desc": model.CoursesSubjects = model.CoursesSubjects.OrderByDescending(cs => cs.Subject.Name).ToList(); break; case "subject_asc": default: model.CoursesSubjects = model.CoursesSubjects.OrderBy(cs => cs.Subject.Name).ToList(); break; } if (submitBtn == "Export") // Export grades for single Student { StringBuilder sb = new StringBuilder(); sb.AppendLine(String.Format("Subject,Grade")); foreach (var cs in model.CoursesSubjects) { double total = 0.0; double avg = 0.0; if (cs.Subject != null) { foreach (var grade in cs.Subject.Grades) { total += grade.GradeValue; } avg = total / cs.Subject.Grades.Count; } sb.AppendLine(String.Format("{0},{1}", cs.Subject.Name, avg)); } string filename = "students-grades-" + model.FacultyNumber + "-" + DateTime.Now.Date + ".csv"; return(File(new System.Text.UTF8Encoding().GetBytes(sb.ToString()), "text/csv", filename)); } return(View(model)); }