////[SwitchableAuthorization] ////[Authorize] public ActionResult Create() { ViewBag.VenueTypes = new SelectList(db.VenueTypes.OrderBy(v => v.TypeName).Where(v=>v.Active).ToList(), "VenueTypeId", "TypeName"); ViewBag.Venues = new SelectList(Enumerable.Empty<SelectListItem>()); ViewBag.Locations = new SelectList(db.Locations.OrderBy(l=>l.Name), "LocationId", "Name"); ViewBag.GenderCounts = new SelectList(Genders.Count, "Id", "Name"); Ticket ticket = new Ticket { TicketDate = DateTime.Now, TicketTime = DateTime.Now.AddMinutes(30), MaleCount = 1, FemaleCount = 2, LocationId = 15, ContactPromoter = false, BottleService = false }; ticket.Customer = new Customer { FirstName = "test", LastName = "test", Email = "*****@*****.**", Phone = "8885551212" }; return View(ticket); }
public ActionResult Create(Ticket appointment) { var date = appointment.TicketDate.Date.ToShortDateString(); var time = ((DateTime)(appointment.TicketTime)).ToString("HH:mm:ss tt"); //var dateTime = IsStripClub(appointment.VenueId) ? DateTime.Parse(date + " " + time) : DateTime.Parse(date); var dateTime = DateTime.Parse(date + " " + time); var repCode = Session["RepCode"] != null ? Session["RepCode"].ToString() : null; var valid = true; string userId = string.Empty; if (!string.IsNullOrEmpty(User.Identity.Name)) { var user = db.Users.SingleOrDefault(u => u.UserName == User.Identity.Name); userId = user.Id; } //if (userId == null && !string.IsNullOrEmpty(repCode)) //{ // var user = db.Users.SingleOrDefault(u => u.UserName == User.Identity.Name); // userId = user.UserId; //} if (IsStripClub(appointment.VenueTypeId) && dateTime < DateTime.Now.AddMinutes(-5)) { valid = false; ModelState.AddModelError(string.Empty, "Appt Date/Time can't be in the past"); } if (IsStripClub(appointment.VenueTypeId) && dateTime > DateTime.Now.AddDays(14)) { valid = false; ModelState.AddModelError(string.Empty, "Appt Date/Time can't be too far in the future"); } if (IsStripClub(appointment.VenueTypeId) && ((appointment.LocationId == null || appointment.LocationId == 0) && string.IsNullOrEmpty(appointment.OtherLocation))) { valid = false; ModelState.AddModelError(string.Empty, "Location is required"); } if (!IsStripClub(appointment.VenueTypeId) && appointment.ServiceId == null) { valid = false; ModelState.AddModelError(string.Empty, "Service option is required for this Venue Type"); } if ((appointment.MaleCount == null || appointment.MaleCount == 0) && (appointment.FemaleCount == null || appointment.FemaleCount == 0)) { valid = false; ModelState.AddModelError(string.Empty, "Male or Female Count is required"); } if (valid && ModelState.IsValid) { appointment.CreatedDate = DateTime.Now; appointment.UpdatedDate = DateTime.Now; appointment.CreatedBy = userId; appointment.UpdatedBy = userId; appointment.TicketDate = dateTime; appointment.StatusId = appointment.ServiceId == (int)VenueServices.GuestList ? (int)AppointmentStatus.Confirmed : (int)AppointmentStatus.PreConfirmed; appointment.PromoterId = userId; appointment.Customer.PromoterId = userId; db.Tickets.Add(appointment); db.SaveChanges(); return RedirectToAction("Success"); } ViewBag.VenueTypes = new SelectList(db.VenueTypes.OrderBy(v => v.TypeName).Where(v => v.Active).ToList(), "VenueTypeId", "TypeName"); ViewBag.Venues = new SelectList(db.Venues.OrderBy(v => v.Name).Where(v => v.Active && (v.VenueTypeId == appointment.VenueTypeId)).ToList(), "VenueId", "Name"); ViewBag.Locations = new SelectList(db.Locations.OrderBy(l => l.Name), "LocationId", "Name"); ViewBag.GenderCounts = new SelectList(Genders.Count, "Id", "Name"); return View(appointment); }
private void LazyLoadAppoinmentObjects(Ticket appointment) { if (appointment.VenueId > 0) { appointment.Venue = db.Venues.Find(appointment.VenueId); } if (appointment.LocationId > 0) { appointment.Location = db.Locations.Find(appointment.LocationId); } if (appointment.ServiceId > 0) { appointment.Service = db.Services.Find(appointment.ServiceId); } }
public ActionResult Edit(Ticket appointment) { if (ModelState.IsValid) { db.Entry(appointment).State = EntityState.Modified; db.SaveChanges(); return RedirectToAction("Index"); } //ViewBag.CustomerId = new SelectList(db.Customers, "CustomerId", "First", appointment.CustomerId); ViewBag.VenueId = new SelectList(db.Venues, "VenueId", "Name", appointment.VenueTypeId); //ViewBag.AgentId = new SelectList(db.Agents, "AgentId", "First", appointment.AgentId); return View(appointment); }