public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(Page()); } Batch.DateModified = DateTime.Now; _context.Attach(Batch).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!BatchExists(Batch.BatchId)) { return(NotFound()); } else { throw; } } return(RedirectToPage("/Coordinator/Management/Batch/Index")); }
public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(Page()); } Supervisor.DateModified = DateTime.Now; _context.Attach(Supervisor).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!SupervisorExists(Supervisor.SupervisorId)) { return(NotFound()); } else { throw; } } SuccessMessage = "Profile modified successfully."; return(RedirectToPage("/Supervisor/Profile/Index")); }
public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(Page()); } Announcement.AnnouncementStatus = "Edited"; Announcement.DateModified = DateTime.Now; _context.Attach(Announcement).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!AnnouncementExists(Announcement.AnnouncementId)) { return(NotFound()); } else { throw; } } SuccessMessage = "Announcement modified successfully."; return(RedirectToPage("/Coordinator/Announcement/Index")); }
public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(Page()); } SubmissionType.EndDate = SubmissionType.EndDate.AddDays(1).AddSeconds(-1); SubmissionType.GraceDate = SubmissionType.GraceDate.AddDays(1).AddSeconds(-1); SubmissionType.Status = "Modified"; SubmissionType.DateModified = DateTime.Now; _context.Attach(SubmissionType).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!SubmissionTypeExists(SubmissionType.SubmissionTypeId)) { return(NotFound()); } else { throw; } } SuccessMessage = "Submission modified successfully."; return(RedirectToPage("/Coordinator/Management/SubmissionType/Index")); }
public async Task <IActionResult> OnPostAsync(int id) { if (!ModelState.IsValid) { return(Page()); } // update proposal status Proposal proposal = await _context.Proposal.Where(s => s.DateDeleted == null).FirstOrDefaultAsync(m => m.ProposalId == id); proposal.ProposalStatus = "In Review"; proposal.DateModified = DateTime.Now; _context.Attach(proposal).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ProposalExists(proposal.ProposalId)) { return(NotFound()); } else { throw; } } // Create new review var review = new Models.Review { ProjectId = proposal.ProjectId, ReviewStatus = "New", DateCreated = DateTime.Now }; _context.Review.Add(review); await _context.SaveChangesAsync(); // Update current project var project = await _context.Project.Where(s => s.DateDeleted == null).FirstOrDefaultAsync(p => p.ProjectId == proposal.ProjectId); project.ProjectStatus = "In Review"; await _context.SaveChangesAsync(); var username = HttpContext.Session.GetString("_username").ToString(); var supervisor = await _context.Supervisor.Where(s => s.DateDeleted == null).FirstOrDefaultAsync(m => m.AssignedId == username); var coordinator = await _context.Coordinator.Where(s => s.DateDeleted == null).FirstOrDefaultAsync(); //Email Handler var mailsubject = "FYP System - Request for Review"; var mailbody = $@"Dear Coordinator, I would like to request for review on my proposal: Project ID: {proposal.Project.AssignedId} Project Name: {proposal.Project.ProjectTitle} Yours Sincerely, {supervisor.SupervisorName} (FYP Supervisor)"; await _emailSender.SendEmailAsync(supervisor.SupervisorEmail, coordinator.CoordinatorEmail, mailsubject, mailbody); // Log Message SuccessMessage = $"Review for {proposal.Project.ProjectTitle} requested!"; return(RedirectToPage("/Supervisor/Project/MyProposal")); }
public async Task <IActionResult> OnPostAsync(int id) { if (!ModelState.IsValid) { return(Page()); } // Update student status Models.Student student = await _context.Student .Include(s => s.Batch) .Include(s => s.User).FirstOrDefaultAsync(m => m.StudentId == id); student.StudentStatus = "On"; student.DateModified = DateTime.Now; _context.Attach(student).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!StudentExists(student.StudentId)) { return(NotFound()); } else { throw; } } var newPassword = RandomPassword(); var hashedPassword = HashPassword(newPassword, student.AssignedId); // Create new user var newUser = new Models.User(student.AssignedId, hashedPassword, "Student") { DateCreated = DateTime.Now }; _context.User.Add(newUser); await _context.SaveChangesAsync(); var user = await _context.User.Where(u => u.DateDeleted == null).FirstOrDefaultAsync(u => u.UserName == student.AssignedId); student.UserId = user.UserId; await _context.SaveChangesAsync(); var username = HttpContext.Session.GetString("_username"); var coordinator = await _context.Coordinator.Where(s => s.DateDeleted == null).FirstOrDefaultAsync(c => c.AssignedId == username); // Email Handler var mailsubject = "FYP System - Login Credentials"; var mailbody = $@"Dear {student.StudentName}, Your login credentials: User Name: {student.AssignedId} Password: {newPassword} Please change your password at Settings. Note : Account without any activity within 3 days after sending this email, may be deactivated. Please contact the Coordinator if you found any problem or difficulty using the system. Thank You. Yours Sincerely, {coordinator.CoordinatorName} (FYP Coordinator)"; await _emailSender.SendEmailAsync(coordinator.CoordinatorEmail, student.StudentEmail, mailsubject, mailbody); // Log Message SuccessMessage = $"Student {student.StudentName} approved!"; return(RedirectToPage("/Coordinator/Student/Index")); }