public void FillInSusiInfo(Student student, StudentInfo studentInfo, IEnumerable<CourseInfo> courseInfo) { // TODO: edit when SUSI API is available student.FirstName = studentInfo.FirstName; student.LastName = studentInfo.LastName; student.Email = "*****@*****.**"; Tuple<int, int> startEndYears = studentInfo.GetStartEndYear(); Bachelor bachelor = new Bachelor { StartYear = startEndYears.Item1, EndYear = startEndYears.Item2, Specialty = StudentManager.programmeMapping[studentInfo.Programme], Subjects = courseInfo.Select(x => x.ToSubject()).ToList(), }; FMIEdu fmiEdu = new FMIEdu { Bachelor = bachelor, }; student.FMIInfo = fmiEdu; db.SaveChanges(); }
public void FillInSusiInfo(Student student, StudentInfo studentInfo, IEnumerable<CourseInfo> courseInfo) { student.FirstName = studentInfo.FirstName; student.LastName = studentInfo.LastName; Tuple<int, int> startEndYears = studentInfo.GetStartEndYear(); Bachelor bachelor = new Bachelor { StartYear = startEndYears.Item1, EndYear = startEndYears.Item2, CurrentCourse = studentInfo.Year, Specialty = StudentManager.programmeMapping[studentInfo.Programme], Subjects = courseInfo.Select(x => x.ToSubject()).ToList(), CurrentAverageGrade = courseInfo.Average(x => x.Grade) }; FMIEdu fmiEdu = new FMIEdu { Bachelor = bachelor, }; student.FMIInfo = fmiEdu; db.SaveChanges(); }
public ActionResult Edit(Student student) { if (ModelState.IsValid) { studentManager.SaveStudent(student); return RedirectToAction("Profile", new { userId = student.UserId }); } else { return View(student); } }
public ActionResult ChangeEmail(Student student) { if (ModelState.IsValid) { db.Students.FirstOrDefault(s => s.UserId == WebSecurity.CurrentUserId).Email = student.Email; db.SaveChanges(); return RedirectToAction("Index"); } else { return View(student); } }
public void AddStudent(int userId, StudentInfo studentInfo, IEnumerable<CourseInfo> courseInfo) { Student student = new Student(); student.UserId = userId; string imageFile = Path.Combine(HttpContext.Current.Server.MapPath("~/Images/default-avatar.jpg")); byte[] buffer = File.ReadAllBytes(imageFile); student.Picture = buffer; this.FillInSusiInfo(student, studentInfo, courseInfo); db.Students.Add(student); db.SaveChanges(); }
public void AddStudent(int userId, StudentInfo studentInfo, IEnumerable<CourseInfo> courseInfo, string userName) { Student student = new Student(); student.UserId = userId; student.Email = userName + "@uni-sofia.com"; string imageFile = Path.Combine(HttpContext.Current.Server.MapPath("~/Images/default-avatar.jpg")); byte[] buffer = File.ReadAllBytes(imageFile); student.Picture = buffer; this.FillInSusiInfo(student, studentInfo, courseInfo); db.Students.Add(student); try { db.SaveChanges(); } catch (Exception e) { throw; } }
public void SaveStudent(Student student) { Student dbEntry = db.Students.Find(student.StudentProfileId); if (dbEntry != null) { // Main info if (student.Picture != null) { dbEntry.Picture = student.Picture; } dbEntry.FirstName = student.FirstName; dbEntry.LastName = student.LastName; dbEntry.Email = student.Email; dbEntry.Blog = student.Blog; dbEntry.Phone = student.Phone; dbEntry.Facebook = student.Facebook; dbEntry.LinkedIn = student.LinkedIn; dbEntry.Twitter = student.Twitter; dbEntry.GooglePlus = student.GooglePlus; dbEntry.Github = student.Github; dbEntry.CV = student.CV; // Education if (student.HighSchoolInfo != null) { dbEntry.HighSchoolInfo = student.HighSchoolInfo; } if (student.FMIInfo != null) { for (int i = 0; i < student.FMIInfo.Bachelor.Subjects.Count; i++) { dbEntry.FMIInfo.Bachelor.Subjects[i].IsVisible = student.FMIInfo.Bachelor.Subjects[i].IsVisible; } } // Experience if (student.Jobs != null && dbEntry.Jobs != null) { for (int i = 0; i < Math.Min(dbEntry.Jobs.Count, student.Jobs.Count); i++) { dbEntry.Jobs[i] = student.Jobs[i]; } } if (student.Projects != null && dbEntry.Projects != null) { for (int i = 0; i < Math.Min(dbEntry.Projects.Count, student.Projects.Count); i++) { dbEntry.Projects[i] = student.Projects[i]; } } if (student.Technologies != null && dbEntry.Technologies != null) { for (int i = 0; i < Math.Min(dbEntry.Technologies.Count, student.Technologies.Count); i++) { dbEntry.Technologies[i] = student.Technologies[i]; } } dbEntry.WorkTimePreference = student.WorkTimePreference; dbEntry.WorkStatus = student.WorkStatus; // Personal if (student.Languages != null && dbEntry.Languages != null) { for (int i = 0; i < Math.Min(dbEntry.Languages.Count, student.Languages.Count); i++) { dbEntry.Languages[i] = student.Languages[i]; } } dbEntry.InterestsString = student.InterestsString; dbEntry.DateOfBirth = student.DateOfBirth; dbEntry.Town = student.Town; } db.SaveChanges(); }