public ActionResult CancelApt(int id, int studentUserId, int interviewerId) { TestDatabaseEntities context = new TestDatabaseEntities(); context.DeleteApt(id, studentUserId, interviewerId); ViewBag.Message = "You have successfully canceled your appointment."; return(RedirectToAction("ProfilePage")); }
public ActionResult DenyApt(string denyCode) { TestDatabaseEntities context = new TestDatabaseEntities(); var v = context.Appointments.Where(x => x.confirmCode == new Guid(denyCode)).FirstOrDefault(); var aptUser = context.UserLogins.Where(x => x.UserID == v.StudentUserID).FirstOrDefault(); var instructor = context.UserLogins.Where(x => x.UserID == v.InstructorUserID).FirstOrDefault(); if (v != null) { context.DeleteApt(v.AppointmentID, aptUser.UserID, instructor.UserID); var fromEmail = new MailAddress("*****@*****.**", "PrepIN Support"); var toEmail = new MailAddress(aptUser.Email); var fromEmailPassword = "******"; string subject = "Denial of Appointment"; string body = "</br> </br> Your appointment with " + instructor.Username.ToString() + " for " + v.Time.ToLongDateString() + " at " + v.Time.ToShortTimeString() + " was denyed. Please choose another time."; var smtp = new SmtpClient { Host = "lv-shared04.cpanelplatform.com", Port = 587, EnableSsl = true, DeliveryMethod = SmtpDeliveryMethod.Network, UseDefaultCredentials = false, Credentials = new NetworkCredential(fromEmail.Address, fromEmailPassword) }; using (var message = new MailMessage(fromEmail, toEmail) { Subject = subject, Body = body, IsBodyHtml = true }) smtp.Send(message); ViewBag.Message = "You have successfully denied the appointment with " + aptUser.Username + "."; return(RedirectToAction("ProfilePage")); } else { ViewBag.Message = "An error has occured. Redirecting you to profile page or login page."; return(RedirectToAction("ProfilePage")); } }