Esempio n. 1
0
 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());
     }
 }
Esempio n. 2
0
 // 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));
 }
Esempio n. 3
0
 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("/"));
 }
Esempio n. 4
0
 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("/"));
 }
Esempio n. 5
0
 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
         }));
     }
 }
Esempio n. 6
0
 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 });
     }
 }