public SeanceModel GetSeanceById(int id)
        {
            _theaterServices = new TheaterServices();
            _hallServices    = new CinemaHallServices();
            _movieServices   = new MovieServices();
            var model = new SeanceModel();

            using (SqlConnection con = new SqlConnection(connect))
            {
                con.Open();
                SqlCommand cmd = new SqlCommand("GetSeanceById", con);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@id", id);
                _adapter = new SqlDataAdapter(cmd);
                _ds      = new DataSet();
                _adapter.Fill(_ds);
                if (_ds.Tables.Count > 0 && _ds.Tables[0].Rows.Count > 0)
                {
                    model.Id         = Convert.ToInt32(_ds.Tables[0].Rows[0]["Id"]);
                    model.Theater    = _theaterServices.GetTheaterBySeance(model.Id);
                    model.CinemaHall = _hallServices.GetCinemaHallById(model.Id);
                    model.Movie      = _movieServices.GetMovieBySeance(model.Id);
                    model.Date       = Convert.ToDateTime(_ds.Tables[0].Rows[0]["Date"]);
                    model.Time       = Convert.ToDateTime((_ds.Tables[0].Rows[0]["Time"]).ToString());
                }
            }
            return(model);
        }
Beispiel #2
0
        public CinemaHallModel GetCinemaHallById(int id)
        {
            _theaterServices = new TheaterServices();
            var model = new CinemaHallModel();

            using (SqlConnection con = new SqlConnection(connect))
            {
                con.Open();
                SqlCommand cmd = new SqlCommand("GetCinemaHallById", con);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@id", id);
                _adapter = new SqlDataAdapter(cmd);
                _ds      = new DataSet();
                _adapter.Fill(_ds);
                if (_ds.Tables.Count > 0 && _ds.Tables[0].Rows.Count > 0)
                {
                    model.Id          = Convert.ToInt32(_ds.Tables[0].Rows[0]["Id"]);
                    model.Theater     = _theaterServices.GetTheaterByCinemaHall(model.Id);
                    model.Number      = Convert.ToInt32(_ds.Tables[0].Rows[0]["Number"]);
                    model.CountPlaces = Convert.ToInt32(_ds.Tables[0].Rows[0]["Count_places"]);
                    model.CountRows   = Convert.ToInt32(_ds.Tables[0].Rows[0]["Count_rows"]);
                }
            }
            return(model);
        }
        public IList <SeanceModel> GetSeanceList()
        {
            _movieServices   = new MovieServices();
            _hallServices    = new CinemaHallServices();
            _theaterServices = new TheaterServices();
            IList <SeanceModel> SeanceList = new List <SeanceModel>();

            _ds = new DataSet();

            using (SqlConnection con = new SqlConnection(connect))
            {
                con.Open();
                SqlCommand cmd = new SqlCommand("GetAllSeance", con);
                cmd.CommandType = CommandType.StoredProcedure;
                _adapter        = new SqlDataAdapter(cmd);
                _adapter.Fill(_ds);
                if (_ds.Tables.Count > 0)
                {
                    for (int i = 0; i < _ds.Tables[0].Rows.Count; i++)
                    {
                        SeanceModel obj = new SeanceModel();
                        obj.Id         = Convert.ToInt32(_ds.Tables[0].Rows[i]["Id"]);
                        obj.Theater    = _theaterServices.GetTheaterBySeance(obj.Id);
                        obj.CinemaHall = _hallServices.GetCinemaHallBySeance(obj.Id);
                        obj.Movie      = _movieServices.GetMovieBySeance(obj.Id);
                        obj.Date       = Convert.ToDateTime(_ds.Tables[0].Rows[i]["Date"]);
                        obj.Time       = Convert.ToDateTime((_ds.Tables[0].Rows[i]["Time"]).ToString());
                        SeanceList.Add(obj);
                    }
                }
            }

            return(SeanceList);
        }
Beispiel #4
0
        public IList <CinemaHallModel> GetCinemaHallList()
        {
            _theaterServices = new TheaterServices();
            IList <CinemaHallModel> cinemaHallList = new List <CinemaHallModel>();

            _ds = new DataSet();

            using (SqlConnection con = new SqlConnection(connect))
            {
                con.Open();
                SqlCommand cmd = new SqlCommand("GetAllCinemaHall", con);
                cmd.CommandType = CommandType.StoredProcedure;
                _adapter        = new SqlDataAdapter(cmd);
                _adapter.Fill(_ds);
                if (_ds.Tables.Count > 0)
                {
                    for (int i = 0; i < _ds.Tables[0].Rows.Count; i++)
                    {
                        CinemaHallModel obj = new CinemaHallModel();
                        obj.Id          = Convert.ToInt32(_ds.Tables[0].Rows[i]["Id"]);
                        obj.Theater     = _theaterServices.GetTheaterByCinemaHall(obj.Id);
                        obj.Number      = Convert.ToInt32(_ds.Tables[0].Rows[i]["Number"]);
                        obj.CountPlaces = Convert.ToInt32(_ds.Tables[0].Rows[i]["Count_places"]);
                        obj.CountRows   = Convert.ToInt32(_ds.Tables[0].Rows[i]["Count_rows"]);
                        cinemaHallList.Add(obj);
                    }
                }
            }

            return(cinemaHallList);
        }