예제 #1
0
 public static bool Login(string username, string password)
 {
     using (mCinemaSeatingEntities entities = new mCinemaSeatingEntities())
     {
         return(entities.Users.Any(user => (user.username == username && user.password == password)));
     }
 }
예제 #2
0
        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);
            }
        }
예제 #3
0
        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);
            }
        }
예제 #4
0
 public Visitor Get(string ID)
 {
     using (mCinemaSeatingEntities entities = new mCinemaSeatingEntities())
     {
         return(entities.Visitors.FirstOrDefault(e => e.VisitorID == ID));
     }
 }
예제 #5
0
 public IEnumerable <CinemaHall> GetAll(int x)
 {
     using (mCinemaSeatingEntities entities = new mCinemaSeatingEntities())
     {
         return(entities.CinemaHalls);
     }
 }
예제 #6
0
        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);
            }
        }
예제 #7
0
 //id : sectionID
 public List <pGetSeats_Result> GetAll(string id)
 {
     using (mCinemaSeatingEntities entities = new mCinemaSeatingEntities())
     {
         return(entities.pGetSeats(id).ToList());
     }
 }