public IList <TheaterModel> GetTheaterList()
        {
            IList <TheaterModel> theaterList = new List <TheaterModel>();

            _ds = new DataSet();

            using (SqlConnection con = new SqlConnection(connect))
            {
                con.Open();
                SqlCommand cmd = new SqlCommand("GetAllMovieTheater", 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++)
                    {
                        TheaterModel obj = new TheaterModel();
                        obj.Id         = Convert.ToInt32(_ds.Tables[0].Rows[i]["Id"]);
                        obj.Name       = Convert.ToString(_ds.Tables[0].Rows[i]["Name"]);
                        obj.Adress     = Convert.ToString(_ds.Tables[0].Rows[i]["Address"]);
                        obj.CountHalls = Convert.ToInt32(_ds.Tables[0].Rows[i]["Count_cinema_hall"]);
                        theaterList.Add(obj);
                    }
                }
            }

            return(theaterList);
        }
        public ActionResult AddTheater(TheaterModel model)
        {
            _theaterServices = new TheaterServices();
            _theaterServices.InsertTheater(model);

            return(RedirectToAction("ListTheater"));
        }
 public void InsertTheater(TheaterModel model)
 {
     using (SqlConnection con = new SqlConnection(connect))
     {
         con.Open();
         SqlCommand cmd = new SqlCommand("AddMovieTheater", con);
         cmd.CommandType = CommandType.StoredProcedure;
         cmd.Parameters.AddWithValue("@name", model.Name);
         cmd.Parameters.AddWithValue("@address", model.Adress);
         cmd.Parameters.AddWithValue("@count_hall", model.CountHalls);
         cmd.ExecuteNonQuery();
     }
 }
        public TheaterModel GetTheaterById(int id)
        {
            var model = new TheaterModel();

            using (SqlConnection con = new SqlConnection(connect))
            {
                con.Open();
                SqlCommand cmd = new SqlCommand("GetTheaterById", con);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@id_movie", 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.Name       = Convert.ToString(_ds.Tables[0].Rows[0]["Name"]);
                    model.Adress     = Convert.ToString(_ds.Tables[0].Rows[0]["Address"]);
                    model.CountHalls = Convert.ToInt32(_ds.Tables[0].Rows[0]["Count_cinema_hall"]);
                }
            }
            return(model);
        }
 public ActionResult EditTheater(TheaterModel model)
 {
     _theaterServices = new TheaterServices();
     _theaterServices.UpdateTheater(model);
     return(RedirectToAction("ListTheater"));
 }
Exemple #6
0
 public IActionResult DeleteTheater(TheaterModel theatermodel)
 {
     _Dbcontext.Remove(theatermodel).State = EntityState.Deleted;
     _Dbcontext.SaveChanges();
     return(RedirectToAction("index"));
 }
Exemple #7
0
 public IActionResult EditTheater(TheaterModel theatermodel)
 {
     _Dbcontext.Entry(theatermodel).State = EntityState.Modified;
     _Dbcontext.SaveChanges();
     return(RedirectToAction("index"));
 }
Exemple #8
0
 public IActionResult CreateTheater(TheaterModel theater)
 {
     _Dbcontext.TheaterModels.Add(theater);
     _Dbcontext.SaveChanges();
     return(RedirectToAction("index"));
 }