public ActionResult Search(int?appointmentID, string clientPassword) { if (appointmentID == null) { return(View()); } tblAppointment tblAppointment = db.tblAppointments.Find(appointmentID); try { string salt = tblAppointment.tblClient.salt; if ((Crypto.VerifyHashedPassword(tblAppointment.tblClient.Password, clientPassword + salt)) || (Session["user"] != null)) { TempData["userInfo"] = tblAppointment.appointmentID; tblEmployee tblEmployee = db.tblEmployees.Find(tblAppointment.employeeID); tblHaircut tblHaircut = db.tblHaircuts.Find(tblAppointment.haircutID); ViewData["timeSlot"] = tblAppointment.tblTimeSlot.timeSlot; ViewData["employee"] = tblEmployee.FirstName + " " + tblEmployee.LastName; ViewData["haircut"] = tblHaircut.HaircutName; if ((tblAppointment == null) || (tblEmployee == null) || (tblHaircut == null)) { return(HttpNotFound()); } return(View(tblAppointment)); } } catch (Exception) { ViewBag.searchError = "No appointment could be found please try again later!"; } return(View()); }
public async Task <ActionResult> appointmentConfirmation(int?appointmentID) { if (appointmentID == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } tblAppointment tblAppointment = await db.tblAppointments.FindAsync(appointmentID); tblEmployee tblEmployee = await db.tblEmployees.FindAsync(tblAppointment.employeeID); tblHaircut tblHaircut = await db.tblHaircuts.FindAsync(tblAppointment.haircutID); tblTimeSlot tblTimeSlot = await db.tblTimeSlots.FindAsync(tblAppointment.timeSlotID); ViewData["employee"] = tblEmployee.FirstName + " " + tblEmployee.LastName; ViewData["haircut"] = tblHaircut.HaircutName; ViewData["timeSlot"] = tblTimeSlot.timeSlot; if (TempData["userInfo"] != null) { TempData.Keep("userInfo"); } if (tblAppointment == null) { return(HttpNotFound()); } return(View(tblAppointment)); }
public async Task <ActionResult> HaircutDeleteConfirmed(int id) { if (Session["user"] != null) { tblHaircut tblHaircut = await db.tblHaircuts.FindAsync(id); var typeID = tblHaircut.TypeID; db.tblHaircuts.Remove(tblHaircut); await db.SaveChangesAsync(); return(RedirectToAction("HaircutTypeDetails", "Prices", new { haircutTypeID = typeID })); } else { return(RedirectToAction("Index", "Home")); } }
public async Task <ActionResult> DeleteHaircut(int?id) { if (Session["user"] != null) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } tblHaircut tblHaircut = await db.tblHaircuts.FindAsync(id); if (tblHaircut == null) { return(HttpNotFound()); } return(View(tblHaircut)); } else { return(RedirectToAction("HaircutTypeDetails", "Price")); } }
public async Task <ActionResult> EditHaircuts(int?id) { if (Session["user"] != null) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } tblHaircut tblHaircut = await db.tblHaircuts.FindAsync(id); ViewBag.TypeIDList = new SelectList(db.tblHaircutTypes, "TypeID", "TypeName"); if (tblHaircut == null) { return(HttpNotFound()); } return(View(tblHaircut)); } else { return(RedirectToAction("Index", "Home")); } }
public ActionResult DownloadAppointmentCard(int?appointmentID) { tblAppointment tblAppointment = db.tblAppointments.Find(appointmentID); tblEmployee tblEmployee = db.tblEmployees.Find(tblAppointment.employeeID); tblHaircut tblHaircut = db.tblHaircuts.Find(tblAppointment.haircutID); tblTimeSlot tblTimeSlot = db.tblTimeSlots.Find(tblAppointment.timeSlotID); ViewData["employee"] = tblEmployee.FirstName + " " + tblEmployee.LastName; ViewData["haircut"] = tblHaircut.HaircutName; ViewData["timeSlot"] = tblTimeSlot.timeSlot; if (TempData["userInfo"] != null) { TempData.Keep("userInfo"); } return(new Rotativa.ViewAsPdf("appointmentConfirmation", tblAppointment) { FileName = "Mobile Hairdresser : Appointment Card.pdf", PageSize = Size.A4, PageOrientation = Orientation.Portrait, PageMargins = { Left = 0, Right = 0 }, CustomSwitches = "--print-media-type --zoom 1.3" }); }
public ActionResult confirmationEmail(int appointmentID) { string body; if (TempData["userInfo"] != null) { TempData.Keep("userInfo"); } tblAppointment tblAppointment = db.tblAppointments.Find(appointmentID); tblHaircut tblHaircut = db.tblHaircuts.Find(tblAppointment.haircutID); tblEmployee tblEmployee = db.tblEmployees.Find(tblAppointment.employeeID); tblTimeSlot tblTimeSlot = db.tblTimeSlots.Find(tblAppointment.timeSlotID); using (var stream = new StreamReader(Server.MapPath("//App_Data//emailTemplates/" + "appointmentConfirmation.html"))) { body = stream.ReadToEnd(); } try { string appointmentDate = tblAppointment.appointmentDate.DayOfWeek.ToString() + " " + tblAppointment.appointmentDate.Day + " " + tblAppointment.appointmentDate.ToString("MMMM") + " " + tblAppointment.appointmentDate.Year; TimeSpan appointmentTime = tblTimeSlot.timeSlot; string haircutName = tblHaircut.HaircutName; string employeeName = tblEmployee.FirstName + " " + tblEmployee.LastName; string customerName = tblAppointment.tblClient.clientName; string customerPhoneNumber = tblAppointment.tblClient.clientMobile; string customerEmail = tblAppointment.tblClient.clientEmail; string clientPassword = TempData["userInfo"].ToString(); int customerHouseNumber = Convert.ToInt32(tblAppointment.tblClient.clientHouseNumber); string customerAddress = tblAppointment.tblClient.clientPostalCode; string emailFrom = ConfigurationManager.AppSettings["EmailFormAddress"]; MailMessage confirmationMessage = new MailMessage(); confirmationMessage.To.Add(customerEmail); confirmationMessage.From = new MailAddress(emailFrom, "Mobile Hairdresser"); confirmationMessage.ReplyToList.Add(new MailAddress(customerEmail)); confirmationMessage.Subject = @"Mobile Hairdresser : Appointment Confirmation"; confirmationMessage.Body = string.Format(body, customerName, customerPhoneNumber, customerEmail, clientPassword , customerHouseNumber, customerAddress, appointmentID, appointmentDate , appointmentTime, employeeName, haircutName); confirmationMessage.IsBodyHtml = true; using (SmtpClient smtp = new SmtpClient()) { smtp.EnableSsl = Convert.ToBoolean(ConfigurationManager.AppSettings["EnableSSL"]); smtp.Host = ConfigurationManager.AppSettings["MailServer"]; smtp.Port = Convert.ToInt32(ConfigurationManager.AppSettings["Port"]); smtp.UseDefaultCredentials = false; smtp.Credentials = new NetworkCredential(ConfigurationManager.AppSettings["MailAuthUser"], ConfigurationManager.AppSettings["MailAuthPass"]); smtp.DeliveryMethod = SmtpDeliveryMethod.Network; smtp.SendCompleted += (s, e) => { smtp.Dispose(); }; smtp.Send(confirmationMessage); } } catch (Exception emailError) { TempData["appointmentConfirmationEmail"] = "An error has occured and your email could not be sent!" + emailError; return(RedirectToAction("appointmentConfirmation", "Appointment", new { appointmentID = tblAppointment.appointmentID })); } TempData["appointmentConfirmationEmail"] = "We have sent you an email confirming your appointment."; return(RedirectToAction("appointmentConfirmation", "Appointment", new { appointmentID = tblAppointment.appointmentID })); }
public async Task <ActionResult> SaveHaircuts(int?HaircutID, string HaircutName, [Bind(Include = "HaircutID,HaircutName,ShortPrice,LongPrice,TimeToCompletion,TypeID")] tblHaircut tblHaircut) { if (Session["user"] != null) { if (ModelState.IsValid) { bool data = db.tblHaircuts.Any(record => record.HaircutID == HaircutID); if (data) { db.Entry(tblHaircut).State = EntityState.Modified; } else { db.tblHaircuts.Add(tblHaircut); } await db.SaveChangesAsync(); return(RedirectToAction("HaircutTypeDetails", "Prices", new { haircutTypeID = tblHaircut.TypeID })); } return(View(tblHaircut)); } else { RedirectToAction("Index", "Home"); } return(View()); }