public ShowView[] View() { using (var data = new lulCinemaEntities()) { return(data.Shows.Where(x => x.time > DateTime.Now).AsEnumerable() .Select(x => new ShowView { Id = x.Id, name = x.name, time = x.time }).ToArray()); } }
// GET: Shows public ActionResult List() { ShowView[] shows; using (var data = new lulCinemaEntities()) { shows = data.Shows.OrderByDescending(x => x.time).AsEnumerable() .Select(x => new ShowView { Id = x.Id, name = x.name, time = x.time }).ToArray(); } return(View(shows)); }
public ActionResult Create(string name, DateTime time) { using (var data = new lulCinemaEntities()) { data.Shows.Add(new Show { name = name, time = time }); data.SaveChanges(); } return(Redirect("/")); }
public ActionResult Edit(int id, string name, DateTime time) { using (var data = new lulCinemaEntities()) { Show s = data.Shows.Find(id); if (s == null) { return(Redirect("/")); } s.name = name; s.time = time; data.SaveChanges(); } return(Redirect("/")); }
public ActionResult Edit(int id) { using (var data = new lulCinemaEntities()) { Show show = data.Shows.Find(id); if (show == null) { return(Redirect("/")); } return(View(new ShowView { Id = show.Id, name = show.name, time = show.time })); } }
public dynamic Buy(int id, short count) { using (var data = new lulCinemaEntities()) { Show show = data.Shows.Find(id); if (show == null) { Request.CreateErrorResponse(HttpStatusCode.NotFound, "Show_not_found"); } data.ShowTickets.Add(new ShowTicket { show = show.Id, count = count, at = DateTime.Now }); data.SaveChanges(); return(new { ok = true }); } }