public ActionResult DeleteConfirmed(string id) { UserTicketForm userTicketForm = db.UserTicketForms.Find(id); db.UserTicketForms.Remove(userTicketForm); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Create([Bind(Include = "UserId,FirstName,LastName,Email,Address1,Address2,City,State,Zip,Country,MaxTickets,RequestTickets,RequestDate,Retiree,RequireTransportation")] UserTicketForm userTicketForm) { if (ModelState.IsValid) { db.UserTicketForms.Add(userTicketForm); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(userTicketForm)); }
// GET: UserTicketForms/Details/5 // select list items //private IEnumerable<SelectListItem> GetRoles() //{ // var dbUserRoles = new DbUserRoles(); // var roles = dbUserRoles // .GetRoles() // .Select(x => // new SelectListItem // { // Value = x.UserRoleId.ToString(), // Text = x.UserRole // }); // return new SelectList(roles, "Value", "Text"); //} public ActionResult Details(string id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } UserTicketForm userTicketForm = db.UserTicketForms.Find(id); if (userTicketForm == null) { return(HttpNotFound()); } return(View(userTicketForm)); }
public ActionResult Edit([Bind(Include = "UserId,FirstName,LastName,Email,Address1,Address2,City,State,Zip,Country,MaxTickets, RequestTickets, RequestDate, Retiree,RequireTransportation")] UserTicketForm userTicketForm) { if (ModelState.IsValid) { try { db.Entry(userTicketForm).State = EntityState.Modified; db.SaveChanges(); var senderEmail = new MailAddress("*****@*****.**", "P&G Boston"); var receiverEmail = new MailAddress(userTicketForm.Email, "Receiver"); //var password = "******"; var sub = "2019 Gillette Family Picnic Ticket Confirmation"; var body = "<HTML> <HEAD> <TITLE> Registration is completed</Title></HEAD><BODY><P> Hello " + CultureInfo.CurrentCulture.TextInfo.ToTitleCase(userTicketForm.FirstName.ToLower()) + ", <br/> <br/>" + "Here is your information that you submitted: </P> <br/> <br/>" + "<table border=\"1\"><tr><th>Full Name</th><th>Additional Ticket Requested</th><th>Max Tickets</th><th>Request Date</th></tr><tr><th>" + userTicketForm.FirstName + " " + userTicketForm.LastName + "</th><th>" + userTicketForm.RequestTickets.ToString() + "</th><th>" + userTicketForm.MaxTickets.ToString() + "</th><th>" + userTicketForm.RequestDate.ToString() + "</th></tr></table>" + "</BODY></HTML>"; var smtp = new SmtpClient { Host = "aero-office.aerofulfillment.com", Port = 25, EnableSsl = false // DeliveryMethod = SmtpDeliveryMethod.Network, // UseDefaultCredentials = false, // Credentials = new NetworkCredential(senderEmail.Address, password) }; using (var mess = new MailMessage(senderEmail, receiverEmail) { Subject = sub, Body = body, IsBodyHtml = true }) { smtp.Send(mess); return(RedirectToAction("Confirmation")); } } catch (DbEntityValidationException e) { ViewBag.ErrorMessage = e.Message; } } return(View(userTicketForm)); }
//translated from navigator public static void UploadExcel(UploadedFile uploadedFile) { try { XLWorkbook Book; IXLWorksheet Sheets; Book = new XLWorkbook(System.Web.HttpContext.Current.Server.MapPath("~/Content/UploadedFiles/") + uploadedFile.FileName); Sheets = Book.Worksheet(1); IXLRange range = Sheets.RangeUsed(); bool firstRow = true; DataTable dt = new DataTable(); foreach (IXLRow row in Sheets.Rows()) { // Use the first row to add columns to DataTable. if (firstRow) { foreach (IXLCell cell in row.Cells()) dt.Columns.Add(cell.Value.ToString()); firstRow = false; } else { UserTicketForm userTicketForm = new UserTicketForm(); userTicketForm.UserId = row.Cell(1).GetValue<String>(); userTicketForm.FirstName = row.Cell(2).GetValue<String>(); userTicketForm.LastName = row.Cell(3).GetValue<String>(); userTicketForm.Email = row.Cell(4).GetValue<String>(); //userTicketForm.Country = row.Cell(10).GetValue<String>(); // tickets is not used on import only when tickets start being requested //if (row.Cell(5).GetValue<Int32>() == null) // { // userTicketForm.Tickets = Convert.ToInt32(row.Cell(5).GetValue<Int32>()); // } // else // { // userTicketForm.Tickets = Convert.ToInt32(row.Cell(5).GetValue<Int32>() ?? 0); // } //if (row.Cell(5).GetValue<Nullable<Int32>>() <= 10) //{ // int n = row.Cell(5).GetValue<Int32>(); // do // { // userTicketForm.MaxTickets = n++; // } while (n <= 10); //} //else //{ // userTicketForm.MaxTickets = 0; //} //userTicketForm.MaxTickets = 0; if (row.Cell(5).GetValue<String>() == "null") { userTicketForm.MaxTickets = 0; } else if (row.Cell(5).GetValue<String>() == "") { userTicketForm.MaxTickets = 0; } else { int n = row.Cell(5).GetValue<Int32>(); if (n <= 10) { userTicketForm.MaxTickets = row.Cell(5).GetValue<Int32>(); } else { userTicketForm.MaxTickets = 0; } } userTicketForm.RequestTickets = row.Cell(6).GetValue<Int32>(); // FIX - change so it checks if by date then row.Cell(7).GetValue<DateTime>(); else force to 1999 //if (row.Cell(7).GetValue<DateTime>() > ) //{ // userTicketForm.RequestDate = DateTime.MinValue; //} //else //{ // userTicketForm.RequestDate = DateTime.MinValue; //} userTicketForm.RequestDate = row.Cell(7).GetValue<DateTime>(); // retiree gets set from customer as 0 or 1 if (row.Cell(8).GetValue<Int32>() <= 1) { if (row.Cell(8).GetValue<Int32>() == 1) { userTicketForm.Retiree = true; } else { userTicketForm.Retiree = false; } } else if (row.Cell(8).GetValue<String>() == "yes") { userTicketForm.Retiree = true; } else if (row.Cell(8).GetValue<String>() == "no") { userTicketForm.Retiree = false; } else if (row.Cell(8).GetValue<Boolean>() == true) { userTicketForm.Retiree = true; } else { userTicketForm.Retiree = false; } userTicketForm.Address1 = row.Cell(9).GetValue<String>(); userTicketForm.Address2 = row.Cell(10).GetValue<String>(); userTicketForm.City = row.Cell(11).GetValue<String>(); userTicketForm.State = row.Cell(12).GetValue<String>(); userTicketForm.Zip = row.Cell(13).GetValue<String>(); // customer sends req trans as 0 for false or 1 true otherwise we expect yes/no true/false if (row.Cell(14).GetValue<Int32>() <= 1) { if (row.Cell(14).GetValue<Int32>() == 1) { userTicketForm.RequireTransportation = true; } else { userTicketForm.RequireTransportation = false; } } else if (row.Cell(14).GetValue<String>() == "yes") { userTicketForm.RequireTransportation = true; } else if (row.Cell(14).GetValue<String>() == "no") { userTicketForm.RequireTransportation = false; } else if (row.Cell(14).GetValue<Boolean>() == true) { userTicketForm.RequireTransportation = true; } else { userTicketForm.RequireTransportation = false; } //userTicketForm.RequireTransportation = row.Cell(14).GetValue<Boolean>(); userTicketForm.Comments = row.Cell(15).GetValue<String>(); userTicketForm.Status = row.Cell(16).GetValue<String>(); userTicketForm.FollowUp = row.Cell(17).GetValue<String>(); db.UserTicketForms.Add(userTicketForm); db.SaveChanges(); } } } catch (Exception e) { string error = e.Message; } }