public static bool Login(string username, string password) { using (mCinemaSeatingEntities entities = new mCinemaSeatingEntities()) { return(entities.Users.Any(user => (user.username == username && user.password == password))); } }
public List <pGetFilms_Result> GetAll(string id) { //List<string> sectionstrs =new List<string>(); //List<Section> secs = new List<Section>(); //using(CinemaSeatingEntities entities = new CinemaSeatingEntities()) //{ // foreach(Film flm in entities.Films) // { // if(flm.FilmName == filmName) // { // sectionstrs.Add(flm.SectionID); // } // } // foreach(Section sec in entities.Sections) // { // if (sectionstrs.Contains(sec.SectionID.ToString())) // { // secs.Add(sec); // } // } // return secs; //} using (mCinemaSeatingEntities entities = new mCinemaSeatingEntities()) { List <pGetFilms_Result> list = entities.pGetFilms(id).ToList(); return(list); } }
public HttpResponseMessage Post([FromBody] User user) { using (mCinemaSeatingEntities entities = new mCinemaSeatingEntities()) { entities.Users.Add(user); try { entities.SaveChanges(); } catch (System.Data.Entity.Validation.DbEntityValidationException dbEx) { Exception raise = dbEx; foreach (var validationErrors in dbEx.EntityValidationErrors) { foreach (var validationError in validationErrors.ValidationErrors) { string message = string.Format("{0}:{1}", validationErrors.Entry.Entity.ToString(), validationError.ErrorMessage); // raise a new exception nesting // the current instance as InnerException raise = new InvalidOperationException(message, raise); } } throw raise; } var messages = Request.CreateResponse(HttpStatusCode.Created, user); return(messages); } }
public Visitor Get(string ID) { using (mCinemaSeatingEntities entities = new mCinemaSeatingEntities()) { return(entities.Visitors.FirstOrDefault(e => e.VisitorID == ID)); } }
public IEnumerable <CinemaHall> GetAll(int x) { using (mCinemaSeatingEntities entities = new mCinemaSeatingEntities()) { return(entities.CinemaHalls); } }
public HttpResponseMessage Post([FromBody] Order order) { using (mCinemaSeatingEntities entities = new mCinemaSeatingEntities()) { entities.Orders.Add(order); int numof = entities.Database.ExecuteSqlCommand(@"UPDATE Seats SET Status = 1 WHERE SeatID ='" + order.SeatID + "' and SectionID = '" + order.SectionID + "';"); try { entities.SaveChanges(); } catch (System.Data.Entity.Validation.DbEntityValidationException dbEx) { Exception raise = dbEx; foreach (var validationErrors in dbEx.EntityValidationErrors) { foreach (var validationError in validationErrors.ValidationErrors) { string message = string.Format("{0}:{1}", validationErrors.Entry.Entity.ToString(), validationError.ErrorMessage); // raise a new exception nesting // the current instance as InnerException raise = new InvalidOperationException(message, raise); } } throw raise; } var messages = Request.CreateResponse(HttpStatusCode.Created, order); return(messages); } }
//id : sectionID public List <pGetSeats_Result> GetAll(string id) { using (mCinemaSeatingEntities entities = new mCinemaSeatingEntities()) { return(entities.pGetSeats(id).ToList()); } }