コード例 #1
0
        /// <summary>
        /// Get at list of schedulers, specified by a movie ID
        /// </summary>
        /// <param name="movieID">ID of the movie</param>
        /// <returns>A list of scheduler objects</returns>
        public List <Scheduler> GetSchedulerListByMovieID(int movieID)
        {
            var db = new ConnectToDatabaseDataContext();
            List <Scheduler> SchList = db.Schedulers.Select(x => x).Where(x => x.MovieID == movieID).ToList();

            return(SchList);
        }
コード例 #2
0
        /// <summary>
        /// Selects the customer with the given phonenumber
        /// </summary>
        /// <param name="phone">The phonenumber which to search for</param>
        /// <returns>returns the customer with the phonernumber, if one exists</returns>
        public Customer GetByPhone(string phone)
        {
            var      db       = new ConnectToDatabaseDataContext();
            Customer customer = db.Customers.Single(x => x.phoneNumber.Equals(phone));

            return(customer);
        }
コード例 #3
0
        public void UpdateSchedulers(int schID, DateTime date, TimeSpan time, int movieID, int hallID)
        {
            var db = new ConnectToDatabaseDataContext();

            db.Connection.Open();
            db.Transaction = db.Connection.BeginTransaction(IsolationLevel.RepeatableRead);

            Scheduler scheduler = db.Schedulers.Single(x => x.SchID == schID);

            scheduler.Date      = date;
            scheduler.Starttime = time;
            scheduler.MovieID   = movieID;
            scheduler.HallID    = hallID;

            try
            {
                db.Transaction.Commit();
                db.Transaction.Dispose();
                db.Connection.Close();
            }
            catch (Exception e)
            {
                db.Transaction.Rollback();
                Console.WriteLine(e.Message);
                db.Connection.Close();
            }
        }
コード例 #4
0
        /// <summary>
        /// Update a customer
        /// </summary>
        /// <param name="customerID">The ID of the customer you want to edit</param>
        /// <param name="name">Name of the customer</param>
        /// <param name="email">Email of the customer</param>
        /// <param name="phone">Phone number of the customer</param>
        /// <param name="password">The new password for the customer</param>
        public void UpdateCustomer(int customerID, string name, string email, string phone, string password)
        {
            ConnectToDatabaseDataContext db = new ConnectToDatabaseDataContext();

            db.Connection.Open();
            db.Transaction = db.Connection.BeginTransaction(IsolationLevel.RepeatableRead);
            Customer customer = db.Customers.Single(x => x.CusID == customerID);

            customer.mail        = email;
            customer.name        = name;
            customer.phoneNumber = phone;
            customer.password    = password;

            try
            {
                db.Transaction.Commit();
                db.Transaction.Dispose();
                db.Connection.Close();
            }
            catch (Exception e)
            {
                db.Transaction.Rollback();
                Console.WriteLine(e.Message);
                db.Connection.Close();
            }
        }
コード例 #5
0
        /// <summary>
        /// Gets a seat object by it's scheduler ID and row
        /// </summary>
        /// <param name="schID">The scheduler ID of the seats</param>
        /// <param name="row">The row of the seats</param>
        /// <returns>A list of the seats with that row (should only be 1 though)</returns>
        public List <Seat> GetSeatsBySchIDAndRow(int schID, int row)
        {
            ConnectToDatabaseDataContext db = new ConnectToDatabaseDataContext();
            List <Seat> record = db.Seats.Where(x => x.SchedulerID == schID && x.Row == row).ToList();

            return(record);
        }
コード例 #6
0
        /// <summary>
        /// Inserts a scheduler into the database
        /// </summary>
        /// <param name="date"></param>
        /// <param name="time"></param>
        /// <param name="movieID">The ID of the movie that is to be scheduled</param>
        /// <param name="hallID">The ID of the hall in which the movie will be shown</param>
        public void InsertScheduler(DateTime date, TimeSpan time, int movieID, int hallID)
        {
            var db = new ConnectToDatabaseDataContext();

            Scheduler sch = new Scheduler();

            sch.Date      = date;
            sch.Starttime = time;
            sch.MovieID   = movieID;
            sch.HallID    = hallID;

            db.Schedulers.InsertOnSubmit(sch);


            var result       = (from t in db.Schedulers orderby t.SchID descending select t.SchID).First();
            var HallSeatList = db.HallSeats.Select(x => x).Where(x => x.HallID == hallID);

            foreach (HallSeat hallSeat in HallSeatList)
            {
                Seat seat = new Seat();
                seat.Row         = hallSeat.Row;
                seat.ColumnArray = hallSeat.seatNumbers;
                seat.SchedulerID = result;
                db.Seats.InsertOnSubmit(seat);
            }
        }
コード例 #7
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="resID">The reservation ID, of the reservation that has to be edited</param>
        /// <param name="customerID">Customer ID, if it needs to be changes to a new customer</param>
        /// <param name="row">The rows the reservation has made</param>
        /// <param name="seat">The seats the reservation has made</param>
        /// <param name="schID">Scheduler ID for the reservation, if it needs to be changed</param>
        public void UpdateReservation(int resID, int customerID, string row, string seat, int schID)
        {
            ConnectToDatabaseDataContext db = new ConnectToDatabaseDataContext();

            db.Connection.Open();
            db.Transaction = db.Connection.BeginTransaction(IsolationLevel.RepeatableRead);
            Reservation reservation = db.Reservations.First(r => r.ResID == resID);

            reservation.CustomerID  = customerID;
            reservation.Row         = row;
            reservation.Seat        = seat;
            reservation.SchedulerID = schID;

            try
            {
                db.Transaction.Commit();
                db.Transaction.Dispose();
                db.Connection.Close();
            }
            catch (Exception e)
            {
                db.Transaction.Rollback();
                Console.WriteLine(e);
                db.Connection.Close();
            }
        }
コード例 #8
0
        /// <summary>
        /// Deletes a movie from the database
        /// </summary>
        /// <param name="movie">The movie to delete, of type movie object</param>
        /// <returns>A control int to check for success</returns>
        public int DeleteMovie(Movie movie)
        {
            int controlInt = -1;
            var db         = new ConnectToDatabaseDataContext();

            Movie movieToDelete = new Movie();

            movieToDelete.name     = movie.name;
            movieToDelete.MovieID  = movie.MovieID;
            movieToDelete.Playtime = movie.Playtime;
            movieToDelete.Image    = movie.Image;
            movieToDelete.Price    = movie.Price;

            db.Movies.Attach(movieToDelete);
            db.Movies.DeleteOnSubmit(movieToDelete);

            try
            {
                controlInt = 1;
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }

            return(controlInt);
        }
コード例 #9
0
        /// <summary>
        /// Selects all customers with a given name
        /// </summary>
        /// <param name="name">The name which to search for</param>
        /// <returns>Returns a list of all customers with the name</returns>
        public IEnumerable GetCustomerByName(string name)
        {
            var db = new ConnectToDatabaseDataContext();

            var customer = db.Customers.Select(x => x).AsEnumerable().Where(x => x.name.Equals(name));

            return(customer);
        }
コード例 #10
0
        /// <summary>
        /// Creates a list with all customers
        /// </summary>
        /// <returns>The list of customers</returns>
        public IEnumerable GetAllCustomers()
        {
            var db = new ConnectToDatabaseDataContext();

            var customer = db.Customers.Select(x => x).AsEnumerable();

            return(customer);
        }
コード例 #11
0
        /// <summary>
        /// Gets a movie by it's name
        /// </summary>
        /// <param name="name">Name of the movie</param>
        /// <returns>A movie of a movie object</returns>
        public Movie GetByMovieName(string name)
        {
            var db = new ConnectToDatabaseDataContext();

            Movie movie = db.Movies.Single(x => x.name.Equals(name));

            return(movie);
        }
コード例 #12
0
        /// <summary>
        /// Gets a hall by it's ID
        /// </summary>
        /// <param name="hallID">The ID of the hall</param>
        /// <returns>Returns a hall of type hall object</returns>
        public Hall GetByHallID(int hallID)
        {
            var db = new ConnectToDatabaseDataContext();

            Hall hall = db.Halls.Single(x => x.HallID == hallID);

            return(hall);
        }
コード例 #13
0
        /// <summary>
        /// Gets all movies
        /// </summary>
        /// <returns>Returns an List of all the movies</returns>
        public List <Movie> GetAllMovies()
        {
            var db = new ConnectToDatabaseDataContext();

            var movies = db.Movies.Select(x => x).ToList();

            return(movies);
        }
コード例 #14
0
        //  public Customer CustomerLogin(string userMail, string passWord)

        /// <summary>
        /// Find a customer by e-mail
        /// </summary>
        /// <param name="email">The e-mail of the customer</param>
        /// <returns>The customer object</returns>
        public Customer GetCustomerByEmail(string email)
        {
            var db = new ConnectToDatabaseDataContext();

            var customer = db.Customers.Select(x => x).AsEnumerable().Single(x => x.mail == email);

            return(customer);
        }
コード例 #15
0
        /// <summary>
        /// Find a scheduler by movie
        /// </summary>
        /// <param name="movieID">The ID of the movie</param>
        /// <returns>Returns the scheduler as a scheduler object</returns>
        public Scheduler GetSchedulerByMovieID(int movieID)
        {
            var db = new ConnectToDatabaseDataContext();

            Scheduler scheduler = db.Schedulers.Single(dbScheduler => dbScheduler.MovieID == movieID);

            return(scheduler);
        }
コード例 #16
0
        //Use LINQ to get the schedulers where the schedulerID is x. (See inside SchedulerController.cs)
        /// <summary>
        /// Gets a scheduler by ID
        /// </summary>
        /// <param name="schedulerID">The ID of the scheduler</param>
        /// <returns>Returns the scheduler</returns>
        public Scheduler GetSchedulerByID(int schedulerID)
        {
            var db = new ConnectToDatabaseDataContext();

            Scheduler scheduler = db.Schedulers.Single(x => x.SchID == schedulerID);

            return(scheduler);
        }
コード例 #17
0
        /// <summary>
        /// Finds a customer by the customer ID
        /// </summary>
        /// <param name="customerID">The customer ID you want to search for</param>
        /// <returns>The customer, if it's found</returns>
        public Customer GetCustomerByID(int customerID)
        {
            var db = new ConnectToDatabaseDataContext();

            Customer customer = db.Customers.Single(x => x.CusID == customerID);

            return(customer);
        }
コード例 #18
0
        /// <summary>
        /// Gets all schedulers
        /// </summary>
        /// <returns>A list of schedulers</returns>
        public List <Scheduler> GetAllSchedulers()
        {
            var db = new ConnectToDatabaseDataContext();

            var schedulerList = db.Schedulers.Select(x => x);


            return(schedulerList.ToList());
        }
コード例 #19
0
        /// <summary>
        /// Gets a movie by the ID of a movie
        /// </summary>
        /// <param name="movieID">The ID of the movie</param>
        /// <returns>A movie of a movie object</returns>
        public Movie GetMovieByID(int movieID)
        {
            var db = new ConnectToDatabaseDataContext();

            //   Movie movie = db.Movies.Single(x => x.MovieID == movieID);
            Movie movie = db.Movies.Single(x => x.MovieID == movieID);

            return(movie);
        }
コード例 #20
0
        /// <summary>
        /// Gets all halls with a given name (in case some have the same name)
        /// </summary>
        /// <param name="name">Name of the hall</param>
        /// <returns>Returns an IEnumerable with all the halls with the name</returns>
        public IEnumerable GetHallByName(string name)
        {
            ArrayList hallList = new ArrayList();

            var db = new ConnectToDatabaseDataContext();

            var hall = db.Halls.Select(x => x).AsEnumerable().Where(x => x.name.Equals(name));

            return(hall);
        }
コード例 #21
0
        /// <summary>
        /// Gets all halls
        /// </summary>
        /// <returns>An IEnumerable with all halls</returns>
        public IEnumerable GetAllHalls()
        {
            ArrayList hallList = new ArrayList();

            var db = new ConnectToDatabaseDataContext();

            var hall = db.Halls.Select(x => x).AsEnumerable();

            return(hall);
        }
コード例 #22
0
        /// <summary>
        /// Gets a scheduler by date and time
        /// </summary>
        /// <param name="date">Date and time writen as yyyyMMdd hhMMss</param>
        /// <returns>A list of schedulers</returns>
        public List <Scheduler> GetByDate(DateTime date)
        {
            var db               = new ConnectToDatabaseDataContext();
            var Schedulerlist    = db.Schedulers.Select(x => x).Where(x => x.Date == date);
            List <Scheduler> Sch = new List <Scheduler>();

            Sch = Schedulerlist.ToList();

            return(Sch);
        }
コード例 #23
0
        /// <summary>
        /// A method to reset the database with an SQL script
        /// </summary>
        public void ResetDatabase()
        {
            var db = new ConnectToDatabaseDataContext();

            FileInfo file = new FileInfo("SQLscriptCinema.sql");

            string script = file.OpenText().ReadToEnd();

            db.ExecuteCommand(script);
        }
コード例 #24
0
        /// <summary>
        /// Gets a list reservations by phone number of the customer
        /// </summary>
        /// <param name="phone">The customers phone number</param>
        /// <returns>Returns the list of the reservations</returns>
        public List <Reservation> GetReservationByCusPhone(string phone)
        {
            DBCustomer dbC = new DBCustomer();
            Customer   cus = dbC.GetByPhone(phone);
            int        id  = cus.CusID;

            List <Reservation> list = new List <Reservation>();
            var db = new ConnectToDatabaseDataContext();

            list = db.Reservations.Select(x => x).Where(x => x.CustomerID == id).ToList();
            return(list);
        }
コード例 #25
0
        public IEnumerable GetReservation()
        {
            ConnectToDatabaseDataContext db = new ConnectToDatabaseDataContext();
            DBCustomer         dbCustomer   = new DBCustomer();
            List <Customer>    customers    = dbCustomer.GetAllCustomers().Cast <Customer>().ToList();
            List <Reservation> reservation  = db.Reservations.Select(x => x).AsEnumerable().ToList();

            var cusResJoin = from res in reservation
                             join cust in customers on res.CustomerID equals cust.CusID
                             select res;

            return(cusResJoin);
        }
コード例 #26
0
        /// <summary>
        /// Inserts a scheduler into the database
        /// </summary>
        /// <param name="sch">The object to insert</param>
        public void InsertScheduler(Scheduler sch)
        {
            var db = new ConnectToDatabaseDataContext();

            db.Schedulers.InsertOnSubmit(sch);
            try
            {
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
コード例 #27
0
        //Innerjoin som joiner tabellerne scheduler, movie og hall


        public IEnumerable GetScheduler()
        {
            var db = new ConnectToDatabaseDataContext();

            DBMovie          dbMovie   = new DBMovie();
            List <Movie>     movie     = dbMovie.GetAllMovies().Cast <Movie>().ToList();
            List <Scheduler> scheduler = db.Schedulers.Select(x => x).AsEnumerable().ToList();

            var InnerJoin = from sch in scheduler
                            join mov in movie on sch.MovieID equals mov.MovieID
                            select sch;


            return(InnerJoin);
        }
コード例 #28
0
        /// <summary>
        /// Gets all seats in a given scheduler
        /// </summary>
        /// <param name="schID">The ID of the scheduler</param>
        /// <returns>Returns a list of the seats</returns>
        public List <Seat> GetSeats(int schID)
        {
            ConnectToDatabaseDataContext db = new ConnectToDatabaseDataContext();
            List <Seat> seat = db.Seats.Where(x => x.SchedulerID == schID).ToList();

            return(seat);
            // Testing translater
            //Console.WriteLine(count);
            //for (int column = 0; column < count; column++)
            //{
            //    for (int number = 0; number < jagged[column].Count(); number++)
            //    {
            //        Console.WriteLine(jagged[column][number]);
            //    }
            //    Console.ReadLine();
            //}
        }
コード例 #29
0
        public void DeleteSch(int schID)
        {
            var       db        = new ConnectToDatabaseDataContext();
            Scheduler scheduler = db.Schedulers.Single(x => x.SchID == schID);

            //Scheduler DelScheduler = new Scheduler();
            //DelScheduler.SchID = scheduler.SchID;
            db.Schedulers.DeleteOnSubmit(scheduler);

            try
            {
            }
            catch
            {
                Console.Write("Delete scheduler failed");
            }
        }
コード例 #30
0
        /// <summary>
        /// A login method for a user
        /// </summary>
        /// <param name="userMail">The user e-mail</param>
        /// <param name="passWord">The user password</param>
        /// <returns>Returns true if the user logged in successfully, false if not</returns>
        public Customer CustomerLogin(string userMail, string passWord)

        {
            try
            {
                var db = new ConnectToDatabaseDataContext();

                Customer user = (from c in db.Customers where c.mail.ToLower() == userMail.ToLower() && c.password == passWord select c).SingleOrDefault();

                if (user.CusID > 0)
                {
                    return(user);
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Trace.WriteLine("[ValidateUser] Exception " + ex.Message);
            }

            return(null);
        }