public ActionResult Send(int id = 0) { Notification notification = db.Notifications.Find(id); db.Entry(notification).CurrentValues.SetValues(SendNotification(notification)); db.SaveChanges(); return(RedirectToAction("Index", new { notification_id = id })); }
public ActionResult AssignMultiple(InterviewAssignMultipleViewModel ViewModel) { int auto_assigned_count = 0; Program program = db.Programs.Find(ViewModel.program_id); if (program == null) { Session["FlashMessage"] = "Program not found."; } try { foreach (var interview in program.Interviews.Where(i => i.Applications.Count() < i.no_of_interviewee)) { string department = null; var applications = program.Applications.Where(a => a.Interviews.Count() == 0 && a.ApplicationStatus.name == "Processed"); //sort applications by department is sort_by_dept is true, ,or continuous_assign is false if (ViewModel.sort_by_dept || !ViewModel.continuous_assign) { applications = applications.OrderBy(a => a.StudentProfile.academic_organization); } foreach (var application in applications) { //check if student academic organization is set in avoided session and collide with interview session bool avoided = CheckAvoidedSessions(interview, ViewModel.avoided_sessions, application.StudentProfile); if (!avoided && interview.Applications.Count() < interview.no_of_interviewee) { //check if same department in a single interview if continuous_assign is false if (ViewModel.continuous_assign || department == null || department == application.StudentProfile.academic_organization) { interview.Applications.Add(application); application.Interviews.Add(interview); auto_assigned_count++; department = application.StudentProfile.academic_organization; } } } } db.Entry(program).State = EntityState.Modified; db.SaveChanges(); var available_interview_seat_count = program.Interviews.Sum(i => i.no_of_interviewee - i.Applications.Count()); int unassigned_application_count = program.Applications.Where(a => a.ApplicationStatus.name == "Processed" && a.Interviews.Count() == 0).Count(); Session["FlashMessage"] = "<b>Auto assign summary:</b><br/>" + "Auto-assigned Applications : " + auto_assigned_count + "<br/>" + "Available seats: " + available_interview_seat_count + "<br/>" + "Unassigned Applications : " + unassigned_application_count; return(RedirectToAction("Index")); } catch (Exception e) { Session["FlashMessage"] = "Failed to assign applications to interview timeslots." + (e.Message); return(RedirectToAction("AssignMultiple")); } }
public ActionResult Edit(StudentQualification studentqualification) { if (ModelState.IsValid) { db.Entry(studentqualification).State = EntityState.Modified; db.SaveChanges(); } return(RedirectToAction("MyQualification", "StudentProfile", new { student_id = studentqualification.student_id })); }
public ActionResult Edit(StudentExperience studentexperience) { if (ModelState.IsValid) { db.Entry(studentexperience).State = EntityState.Modified; db.SaveChanges(); } return(RedirectToAction("MyExperience", "StudentProfile", new { student_id = studentexperience.student_id })); }
public ActionResult Edit(StudentActivity studentactivity, string opener_id = null) { if (ModelState.IsValid) { db.Entry(studentactivity).State = EntityState.Modified; db.SaveChanges(); } return(RedirectToAction("ActivityRecord", "StudentProfile", new { student_id = studentactivity.student_id, opener_id = opener_id })); }
public ActionResult Edit(NotificationStatus notificationstatus) { if (ModelState.IsValid) { db.Entry(notificationstatus).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(notificationstatus)); }
public ActionResult Edit(InterviewVenue interviewvenue) { if (ModelState.IsValid) { db.Entry(interviewvenue).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(interviewvenue)); }
public ActionResult Edit(StudentParticularType studentparticulartype) { if (ModelState.IsValid) { db.Entry(studentparticulartype).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(studentparticulartype)); }
public ActionResult EditLanguage(List <StudentParticular> particulars) { foreach (var particular in particulars) { if (particular.id == 0) { if (!String.IsNullOrEmpty(particular.name)) { db.StudentParticulars.Add(particular); } } else { db.Entry(particular).State = EntityState.Modified; } } db.SaveChanges(); return(RedirectToAction("MyParticular", "StudentProfile", new { student_id = User.Identity.Name })); }
public ActionResult Edit(AppointmentConcern appointmentconcern) { if (ModelState.IsValid) { db.Entry(appointmentconcern).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(appointmentconcern)); }
public ActionResult Edit(NotificationType notificationtype) { if (ModelState.IsValid) { db.Entry(notificationtype).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.templateList = new SelectList(db.NotificationTemplates.Where(t => t.type_id == notificationtype.id), "id", "name"); return(View(notificationtype)); }
public ActionResult Edit(InterviewComment interviewcomment) { try { interviewcomment.modified = DateTime.Now; interviewcomment.modified_by = User.Identity.Name; db.Entry(interviewcomment).State = EntityState.Modified; db.SaveChanges(); } catch (Exception e) { return(HttpNotFound("Failed to edit Interview Comment.<br/><br/>" + e.Message)); } return(RedirectToAction("Index", "InterviewComment", new { interview_id = interviewcomment.interview_id })); }
public ActionResult Edit(ProgramStatus programstatus) { if (ModelState.IsValid) { db.Entry(programstatus).State = EntityState.Modified; try { db.SaveChanges(); } catch (Exception e) { Session["FlashMessage"] = "Failed to update status." + e.Message; return(View(programstatus)); } return(RedirectToAction("Index")); } return(View(programstatus)); }
public ActionResult Edit(ApplicationStatus applicationstatus) { if (ModelState.IsValid) { try { db.Entry(applicationstatus).State = EntityState.Modified; db.SaveChanges(); } catch (Exception e) { Session["FlashMessage"] = "Failed to edit status." + e.Message; return(View(applicationstatus)); } return(RedirectToAction("Index")); } return(View(applicationstatus)); }
public ActionResult Edit(ExchangeOption exchangeoption) { if (ModelState.IsValid) { db.Entry(exchangeoption).State = EntityState.Modified; try { db.SaveChanges(); } catch (Exception e) { Session["FlashMessage"] = "Failed to edit exchange destination." + e.Message; return(View(exchangeoption)); } return(RedirectToAction("Index")); } return(View(exchangeoption)); }
public ActionResult Edit(AppointmentHostViewModel ViewModel) { if (ModelState.IsValid) { AppointmentHost appointmenthost = db.AppointmentHosts.Find(ViewModel.host.id); db.Entry(appointmenthost).CurrentValues.SetValues(ViewModel.host); appointmenthost.SystemUsers.Clear(); if (ViewModel.users != null) { foreach (var user in ViewModel.users) { appointmenthost.SystemUsers.Add(db.SystemUsers.Find(user.UserId)); } } db.SaveChanges(); return(RedirectToAction("Index")); } return(View(ViewModel)); }
public ActionResult Edit(AppointmentCreateMultipleViewModel ViewModel) { Appointment appointment = db.Appointments.Find(ViewModel.appointment.id); if (ModelState.IsValid) { ViewModel.appointment.end_time = ViewModel.appointment.start_time.AddMinutes(ViewModel.duration); db.Entry(appointment).CurrentValues.SetValues(ViewModel.appointment); appointment.AppointmentConcerns.Clear(); if (ViewModel.concerns != null) { foreach (var concernid in ViewModel.concerns) { var concern = db.AppointmentConcerns.Find(concernid); if (concern != null) { appointment.AppointmentConcerns.Add(concern); } } } db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.statusList = new SelectList(db.AppointmentStatus, "id", "name"); ViewBag.concernList = new SelectList(db.AppointmentConcerns.Where(c => c.program_id == null && !c.custom), "id", "name"); ViewBag.programList = new SelectList(programdb.Programs.Where(p => p.require_appointment), "name", "name"); if (User.IsInRole("Admin") || User.IsInRole("Advising") || User.IsInRole("StudentDevelopment")) { ViewBag.hostList = new SelectList(db.AppointmentHosts, "id", "name"); } else { ViewBag.hostList = new SelectList(db.AppointmentHosts.Where(h => h.SystemUsers.Any(u => u.UserName == User.Identity.Name)), "id", "name"); } ViewBag.venueList = new SelectList(db.AppointmentVenues, "id", "name"); return(View(appointment)); }
public ActionResult Nominate(NominationViewModel ViewModel) { int nominatedStatusId = db.NominationStatus.Where(s => s.name == "Nominated").FirstOrDefault().id; Nomination nomination = ViewModel.nomination; nomination.status_id = nominatedStatusId; db.Entry(nomination).State = EntityState.Modified; foreach (Application application in ViewModel.applications) { var original = db.Applications.Find(application.id); if (application.nominated != original.nominated) { original.modified = DateTime.Now; original.modified_by = User.Identity.Name; original.nominated = application.nominated; db.Entry(original).State = EntityState.Modified; } } db.SaveChanges(); return(RedirectToAction("Nominate", new { id = ViewModel.nomination.id })); }
public ActionResult Edit(StudentAdvisingRemark studentadvisingremark, string opener_id = null) { if (ModelState.IsValid) { var remark = db.StudentAdvisingRemarks.Find(studentadvisingremark.id); if (remark.filename != studentadvisingremark.filename || remark.filepath != studentadvisingremark.filepath) // action only when existing filename is diff from posted one { if (!String.IsNullOrEmpty(remark.filename)) //delete existing file if filename id not empty { var path = Server.MapPath("~/App_Data/" + remark.filepath); var filepath = Path.Combine(path, remark.filename); if (System.IO.File.Exists(filepath)) { try { System.IO.File.Delete(filepath); } catch (Exception e) { Session["FlashMessage"] = "Failed to delete attachment." + e.Message; } } } if (!String.IsNullOrEmpty(studentadvisingremark.filename) && !String.IsNullOrEmpty(studentadvisingremark.filepath)) // move the uploaded file to destination { var sourcePath = Server.MapPath("~/App_Data/" + studentadvisingremark.filepath); var sourceFilepath = Path.Combine(sourcePath, studentadvisingremark.filename); var destPath = Server.MapPath("~/App_Data/" + "Attachments/AdvisingRemark/" + studentadvisingremark.id); var destFilepath = Path.Combine(destPath, studentadvisingremark.filename); try { Directory.CreateDirectory(destPath); } catch (Exception e) { Session["FlashMessage"] = "Failed to create directory." + e.Message; } try { System.IO.File.Move(sourceFilepath, destFilepath); studentadvisingremark.filepath = "Attachments/AdvisingRemark/" + studentadvisingremark.id; } catch (Exception e) { Session["FlashMessage"] = "Failed to move file." + e.Message; } } //clear temp files uploaded but not used if (Directory.Exists(Server.MapPath("~/App_Data/Temp/AdvisingRemark/" + studentadvisingremark.id))) { var files = Directory.GetFiles(Server.MapPath("~/App_Data/Temp/AdvisingRemark/" + studentadvisingremark.id)); foreach (var file in files) { System.IO.File.Delete(file); } } } studentadvisingremark.modified = DateTime.Now; studentadvisingremark.modified_by = User.Identity.Name; db.Entry(remark).CurrentValues.SetValues(studentadvisingremark); db.SaveChanges(); } return(RedirectToAction("AdvisingRemark", "StudentProfile", new { student_id = studentadvisingremark.student_id, opener_id = opener_id })); }
public ActionResult Edit(ProgramType programtype) { if (ModelState.IsValid) { if (!String.IsNullOrEmpty(programtype.image_filename)) { var sourcePath = Server.MapPath("~/App_Data/" + programtype.image_filepath); var sourceFilepath = Path.Combine(sourcePath, programtype.image_filename); var destPath = Server.MapPath("~/Images/ProgramType/" + programtype.id.ToString()); var destFilepath = Path.Combine(destPath, programtype.image_filename); try { Directory.CreateDirectory(destPath); } catch (Exception e) { Session["FlashMessage"] = "Failed to create directory. Please check write permission of ~/Images/ProgramType. <br/><br/>" + e.Message; } try { System.IO.File.Move(sourceFilepath, destFilepath); programtype.image_filepath = "~/Images/ProgramType/" + programtype.id.ToString(); } catch (Exception e) { Session["FlashMessage"] = "Failed to move file. Please check write permission of ~/Images/ProgramType. <br/><br/>" + e.Message; } } //clear temp files uploaded but not used if (Directory.Exists(Server.MapPath("~/App_Data/Temp/ProgramType/" + programtype.id.ToString()))) { var files = Directory.GetFiles(Server.MapPath("~/App_Data/Temp/ProgramType/" + programtype.id.ToString())); foreach (var file in files) { System.IO.File.Delete(file); } } db.Entry(programtype).State = EntityState.Modified; try { db.SaveChanges(); } catch (Exception e) { Session["FlashMessage"] = "Failed to update type." + e.Message; List <SelectListItem> items = new List <SelectListItem>(); items.Add(new SelectListItem { Text = "Application End Time", Value = "deadline", Selected = true }); items.Add(new SelectListItem { Text = "Program Date", Value = "program" }); ViewBag.display_date = items; return(View(programtype)); } return(RedirectToAction("Index")); } return(View(programtype)); }