public ActionResult Create(Show show) { if (ModelState.IsValid) { db.Shows.Add(show); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(show)); }
public ActionResult Create([Bind(Include = "ID,Title,premiereDate,Director,Distributiob,TicketsNumber")] Shows shows) { if (ModelState.IsValid) { db.Shows.Add(shows); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(shows)); }
public ActionResult Create([Bind(Include = "ID,Title,ReleaseDate,Directors,Cast,Tickets")] Show show) { if (ModelState.IsValid && User.IsInRole("Admin")) { db.Shows.Add(show); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(show)); }
public ActionResult AddTicketForSpecifiedShow(Ticket ticket) { if (ModelState.IsValid) { Show show = showDB.Shows.Find(ticket.ShowId); var tickets = from t in db.Tickets select t; if (tickets.Count(s => s.Row == ticket.Row && s.SeatNumber == ticket.SeatNumber) == 0) { db.Tickets.Add(ticket); db.SaveChanges(); //actualizare bilete disponibile show.AvailableTickets = show.AvailableTickets - 1; showDB.Entry(show).State = EntityState.Modified; showDB.SaveChanges(); return(RedirectToAction("EmployeeAfterLogin", "User")); } else { ViewBag.AvailableTickets = "Number of Available Tickets: " + show.AvailableTickets; ViewBag.BiletExistent = "Loc Ocupat!"; return(View(ticket)); } } return(View(ticket)); }
public ActionResult Create([Bind(Include = "ID,BiletLaSpectacol,Rand,Numar")] Tickets tickets) { Boolean ok = true; if (ModelState.IsValid) { foreach (var t1 in db.TicketsList) { if (t1 == null || (t1 != null && !t1.BiletLaSpectacol.Equals(tickets.BiletLaSpectacol))) { ok = true; } else if (t1.Numar.Equals(tickets.Numar)) { ok = false; } } if (ok == true) { db.TicketsList.Add(tickets); db.SaveChanges(); Show show = sDb.Shows.Single(t => t.Title.Contains(tickets.BiletLaSpectacol)); show.Tickets--; sDb.SaveChanges(); return(RedirectToAction("Index")); } else { return(RedirectToAction("Index")); } } return(View(tickets)); }