public async System.Threading.Tasks.Task <ActionResult> Create(Student student, HttpPostedFileBase StudentBirthCertURL, HttpPostedFileBase StudentReportURL, HttpPostedFileBase StudentProofResURL, HttpPostedFileBase StudentPermitURL) { StudentBirthCertURL.SaveAs(Server.MapPath("/") + "/Content/" + StudentBirthCertURL.FileName); student.StudentBirthCertURL = StudentBirthCertURL.FileName; StudentReportURL.SaveAs(Server.MapPath("/") + "/Content/" + StudentReportURL.FileName); student.StudentReportURL = StudentReportURL.FileName; StudentProofResURL.SaveAs(Server.MapPath("/") + "/Content/" + StudentProofResURL.FileName); student.StudentProofResURL = StudentProofResURL.FileName; StudentPermitURL.SaveAs(Server.MapPath("/") + "/Content/" + StudentPermitURL.FileName); student.StudentPermitURL = StudentPermitURL.FileName; student.StudentAllowReg = false; student.Status = "Pending"; var user = new ApplicationUser { UserName = student.StudentEmail, Email = student.StudentEmail }; string pwd = "@User001"; var result = await UserManager.CreateAsync(user, pwd); Logic.CreateAccount(student.StudentEmail); db.students.Add(student); db.SaveChanges(); EmailSender1.SendApplicationEmail(student); UserManager.AddToRole(user.Id, "Student"); TempData["AlertMessage"] = "All your details have been successfully captured and the form has been submitted.\n" + "Please wait for your details to be verified, this may take up to a week and if you are accepted then you will receive a email indicating that you may proceed to registration.\n" + " Thank You!! "; return(RedirectToAction("Index", "Home")); }
public ActionResult DeleteConfirmed(int id) { Student student = db.students.Find(id); db.students.Remove(student); db.SaveChanges(); EmailSender1.SendDeclineEmail(student); return(RedirectToAction("Index")); }
// [ValidateAntiForgeryToken] public ActionResult Edit([Bind(Include = "StID,StudentName,StudentSurname,StudentGender,StudentAddress,StudentTown,StudentContact,StudentGrade,StudentEmail,StudentBirthCertURL,StudentReportURL,StudentProofResURL,StudentPermitURL,StudentAllowReg")] Student student) { if (ModelState.IsValid) { student.Status = "Accepted"; student.StudentAllowReg = true; db.Entry(student).State = EntityState.Modified; db.SaveChanges(); EmailSender1.SendAcceptanceEmail(student); return(RedirectToAction("Index")); } return(View(student)); }
public ActionResult Send_Email(SendEmailViewModel model) { if (ModelState.IsValid) { try { String toEmail = model.ToEmail; String subject = model.Subject; String contents = model.Contents; //var attachment = Request.Files["attachment"]; //if (attachment.ContentLength > 0) //{ // String path = Path.Combine(Server.MapPath("~/Content/Attachment"), attachment.FileName); // attachment.SaveAs(path); // EmailSender1 es = new EmailSender1(); // es.SendWithAttachment(toEmail, subject, contents, path, attachment.FileName); //} //else //{ EmailSender1 es = new EmailSender1(); es.Send(toEmail, subject, contents); //} ViewBag.Result = "Email has been send."; ModelState.Clear(); return(View(new SendEmailViewModel())); } catch { return(View()); } } return(View()); }
public ActionResult Create([Bind(Include = "ReservationId,BookId,ReservationDate,StudentEmail,CollectionDate,ReturnDate,Status")] BookReservation bookReservation) { var userName = User.Identity.GetUserName(); if (ModelState.IsValid) { if (Logic.CheckBooking(bookReservation) == false) { if (Logic.CheckDate(bookReservation.CollectionDate)) { bookReservation.BookId = int.Parse(Session["BookId"].ToString()); bookReservation.StudentEmail = userName; bookReservation.ReservationDate = DateTime.Now.Date; bookReservation.ReturnDate = bookReservation.CollectionDate.AddDays(3); bookReservation.Status = "Reserved"; //Logic.UpdateBookStatus(bookReservation.BookId, bookReservation.Status); Logic.UpdateBookStatus1(bookReservation.BookId, bookReservation.Status); db.BookReservations.Add(bookReservation); db.SaveChanges(); EmailSender1.SendBookingEmail(bookReservation); //Logic.UpdateBookStatus(bookReservation.BookId, "Reserved"); return(RedirectToAction("HowToGetMyOrder", new { id = bookReservation.ReservationId })); } else { ModelState.AddModelError("", "You can not select a date that has already passed"); return(View(bookReservation)); } } else { ModelState.AddModelError("", $"Book is currently reserved., You can book after {bookReservation.CollectionDate.AddDays(3).ToShortDateString()}"); return(View(bookReservation)); } } return(View(bookReservation)); }