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 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 }); } }