Exemplo n.º 1
0
        public Theaters Update(Theaters updatedTheater)
        {
            var entity = db.Theaters.Attach(updatedTheater);

            entity.State = EntityState.Modified;
            return(updatedTheater);
        }
Exemplo n.º 2
0
        public void ShowTheaters()
        {
            Console.Clear();
            int choice = -1;

            while (choice == -1)
            {
                System.Console.WriteLine("Pick a theater");
                var i = 1;
                Theaters.ForEach(theater =>
                {
                    System.Console.WriteLine($@"
        ----------------------------
        |{i}. {theater.Name} | {theater.RoomNumber}
        ----------------------------
            ");
                    i++;
                });
                System.Console.WriteLine("Which theater do you want to pick?");
                var userInput = Console.ReadLine();
                int.TryParse(userInput, out choice);
            }
            activeTheater = Theaters[choice - 1];
            System.Console.WriteLine($"You have selected {activeTheater.Name}");
        }
        // POST api/<controller>
        public void Post()
        {
            Movies movie = new Movies();

            movie.name   = HttpContext.Current.Request.Params["name"];
            movie.date   = Convert.ToDateTime(HttpContext.Current.Request.Params["date"]);
            movie.year   = HttpContext.Current.Request.Params["year"];
            movie.genre  = HttpContext.Current.Request.Params["genre"];
            movie.length = Convert.ToInt32(HttpContext.Current.Request.Params["length"]);
            movie.seats  = Convert.ToInt32(HttpContext.Current.Request.Params["seats"]);

            HttpPostedFile file = HttpContext.Current.Request.Files["img"];

            //string ext = Path.GetExtension(file.FileName);
            file.SaveAs(HttpContext.Current.Server.MapPath("~") + "/images/" + file.FileName);
            movie.movie_img_url = "/images/" + file.FileName;

            Theaters theater = new Theaters();

            theater.hall_num        = Convert.ToInt32(HttpContext.Current.Request.Params["hall_num"]);
            theater.avail_seats_arr = "0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000";

            movie.Theaters.Add(theater);

            CinemaDB db = new CinemaDB();

            db.Movies.Add(movie);
            db.SaveChanges();
        }
Exemplo n.º 4
0
        public IHttpActionResult PutTheaters(int id, Theaters theaters)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != theaters.TheaterId)
            {
                return(BadRequest());
            }

            db.Entry(theaters).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!TheatersExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
        public void Inserttheaters([FromBody] Theaters theater)
        {
            //elasticClient.DeleteIndex("theater_ind");

            if (!elasticClient.Indices.Exists("theater_ind").Exists)
            {
                var indexSettings = new IndexSettings();
                indexSettings.NumberOfReplicas = 1;
                indexSettings.NumberOfShards   = 3;


                var createIndexDescriptor = new CreateIndexDescriptor("theater_ind")
                                            .Mappings(ms => ms
                                                      .Map <Theaters>(m => m.AutoMap())
                                                      )
                                            .InitializeUsing(new IndexState()
                {
                    Settings = indexSettings
                })
                                            .Aliases(a => a.Alias("theaterAlias"));

                var response = elasticClient.Indices.Create(createIndexDescriptor);
            }
            //Insert Data

            elasticClient.Index <Theaters>(theater, idx => idx.Index("theater_ind"));
        }
Exemplo n.º 6
0
        public async Task <IActionResult> Edit(int id, [Bind("ThId,ThName,ThCt,ThWebsite,ThInfo")] Theaters theaters)
        {
            if (id != theaters.ThId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(theaters);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!TheatersExists(theaters.ThId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ThCt"] = new SelectList(_context.Cities, "CtId", "CtName", theaters.ThCt);
            return(View(theaters));
        }
        public TheaterForm(Theaters theater)
        {
            InitializeComponent();
            Theater     = theater;
            this.Cursor = Cursors.WaitCursor;

            var    webClient  = new WebClient();
            var    webClient2 = new WebClient();
            string url        = "http://94.230.164.34:8080/api/PictureTheater?id=" + Theater.Id_theater;

            webClient.DownloadDataCompleted += DownloadDataCompleted;
            webClient.DownloadDataTaskAsync(url);

            theater_name_lbl.Text = Theater.Theater_name;
            site_lbl.Text         = Theater.Theater_site;
            address_lbl.Text     += Theater.Theater_address;
            theater_name_lbl.Left = 750 - theater_name_lbl.Width / 2;
            site_lbl.Left         = 750 - site_lbl.Width / 2;
            address_lbl.Left      = 750 - address_lbl.Width / 2;
            if (Theater.Theater_description != null)
            {
                web.DocumentText = Theater.Theater_description;
            }
            else
            {
                web.DocumentText = Description.empty_description;
            }
        }
Exemplo n.º 8
0
        private void data_theaters_CellContentDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            Theaters theater = new Theaters();

            theater = theaters[e.RowIndex];
            TheaterForm theater_form = new TheaterForm(theater);

            theater_form.Show();
        }
Exemplo n.º 9
0
 public void CreateTheater(string name, int roomNumber, int capacity)
 {
     Theaters.Add(new Theater()
     {
         Name       = name,
         RoomNumber = roomNumber,
         Capacity   = capacity
     });
 }
Exemplo n.º 10
0
        public IHttpActionResult GetTheaters(int id)
        {
            Theaters theaters = db.Theaters.Find(id);

            if (theaters == null)
            {
                return(NotFound());
            }

            return(Ok(theaters));
        }
Exemplo n.º 11
0
        public async Task <IActionResult> Create([Bind("ThId,ThName,ThCt,ThWebsite,ThInfo")] Theaters theaters)
        {
            if (ModelState.IsValid)
            {
                _context.Add(theaters);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ThCt"] = new SelectList(_context.Cities, "CtId", "CtName", theaters.ThCt);
            return(View(theaters));
        }
Exemplo n.º 12
0
        public void Put(int movieNumber, string newSeatsArr)
        {
            CinemaDB db = new CinemaDB();

            Theaters theater = db.Theaters.SingleOrDefault(x => x.movie_number == movieNumber);

            if (theater != null)
            {
                theater.avail_seats_arr = newSeatsArr;
                db.SaveChanges();
            }
        }
Exemplo n.º 13
0
        public void Post(int movieNum, [FromBody] int hallNum)
        {
            Theaters theater = new Theaters();

            theater.movie_number    = movieNum;
            theater.hall_num        = hallNum;
            theater.avail_seats_arr = "0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000";
            CinemaDB db = new CinemaDB();

            db.Theaters.Add(theater);
            db.SaveChanges();
        }
Exemplo n.º 14
0
        public Theaters Update(Theaters updatedTheater)
        {
            var theater = theaters.SingleOrDefault(t => t.Id == updatedTheater.Id);

            if (theater != null)
            {
                theater.Name        = updatedTheater.Name;
                theater.Adress      = updatedTheater.Adress;
                theater.Performance = updatedTheater.Performance;
            }
            return(theater);
        }
Exemplo n.º 15
0
        public IHttpActionResult PostTheaters(Theaters theaters)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.Theaters.Add(theaters);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = theaters.TheaterId }, theaters));
        }
Exemplo n.º 16
0
        public IActionResult Update(string id, Theaters theaterIn)
        {
            var theater = _service.Get(id);

            if (theater == null)
            {
                return(NotFound());
            }

            _service.Update(id, theaterIn);

            return(NoContent());
        }
Exemplo n.º 17
0
        public IHttpActionResult DeleteTheaters(int id)
        {
            Theaters theaters = db.Theaters.Find(id);

            if (theaters == null)
            {
                return(NotFound());
            }

            db.Theaters.Remove(theaters);
            db.SaveChanges();

            return(Ok(theaters));
        }
Exemplo n.º 18
0
        public IActionResult OnGet(int?theaterID)
        {
            Performances = htmlHelper.GetEnumSelectList <PerformanceType>();
            if (theaterID.HasValue)
            {
                Theaters = theaterData.GetById(theaterID.Value);
            }
            else
            {
                Theaters = new Theaters();
            }

            if (Theaters == null)
            {
                return(RedirectToPage("./NotFound"));
            }
            return(Page());
        }
Exemplo n.º 19
0
 public void Update(string id, Theaters theaterIn) =>
 _theaters.ReplaceOne(theater => theater.Id == id, theaterIn);
Exemplo n.º 20
0
 public Theaters Create(Theaters theater)
 {
     _theaters.InsertOne(theater);
     return(theater);
 }
Exemplo n.º 21
0
        public ActionResult <Theaters> Create(Theaters theater)
        {
            _service.Create(theater);

            return(CreatedAtRoute("GetTheater", new { id = theater.Id.ToString() }, theater));
        }
 public void Put(int id, [FromBody] Theaters theater)
 {
     elasticClient.UpdateAsync <Theaters>(id, u => u.Doc(theater));
 }
Exemplo n.º 23
0
 public void Remove(Theaters theaterIn) =>
 _theaters.DeleteOne(theater => theater.Id == theaterIn.Id);
Exemplo n.º 24
0
 public Theaters Add(Theaters newTheater)
 {
     theaters.Add(newTheater);
     newTheater.Id = theaters.Max(t => t.Id) + 1;
     return(newTheater);
 }
Exemplo n.º 25
0
 public Theaters Add(Theaters newTheater)
 {
     db.Add(newTheater);
     return(newTheater);
 }
Exemplo n.º 26
0
 public TheaterSettings GetTheater(TheaterType th)
 {
     return(Theaters.FirstOrDefault(t => t.Type.Equals(th)));
 }
Exemplo n.º 27
0
 public bool SetActiveTheater(TheaterType theater)
 {
     ActiveTheater = Theaters.First(t => t.Type == theater);
     return(ActiveTheater != null);
 }