コード例 #1
0
 public ActionResult CreateHallCinema(int[] halls, int cinema)
 {
     if (ModelState.IsValid)
     {
         CinemaHall cinemaHall = new CinemaHall();
         foreach (var i in halls)
         {
             cinemaHall.CinemaId = cinema;
             cinemaHall.HallId   = i;
             var check = context.CinemaHall.Where(x => x.CinemaId == cinemaHall.CinemaId && x.HallId == cinemaHall.HallId).FirstOrDefault();
             if (check == null)
             {
                 context.CinemaHall.Add(cinemaHall);
                 context.SaveChanges();
             }
             else
             {
                 Session["CinemaHallError"] = true;
                 return(RedirectToAction("CreateHallCinema"));
             }
         }
         return(RedirectToAction("HallCinemaList"));
     }
     return(RedirectToAction("HallCinemaList"));
 }
コード例 #2
0
 public async Task <IEnumerable <Schedule> > FindByCinemaHallAsync(CinemaHall ch)
 {
     return(await Task.FromResult(from s in mockedSchedules
                                  where s.CinemaHall.CinemaHallId == ch.CinemaHallId &&
                                  s.Movie.Archived != true
                                  select s));
 }
コード例 #3
0
ファイル: Program.cs プロジェクト: EnvyIT/apollo
        private static async Task ImportInfrastructure(IUnitOfWork unitOfWork)
        {
            var cinemaHalls = (await unitOfWork.RepositoryInfrastructure.GetCinemaHallsAsync()).ToList();

            if (cinemaHalls.Any())
            {
                Logger.Info("Skipping cinema infrastructure import - already exist...");
            }
            else
            {
                const string cinemaHallName = "Hall of Stars";
                const int    sizeRow        = 20;
                const int    sizeColumn     = 30;

                var cinemaHall = new CinemaHall
                {
                    Id = 1L, Label = cinemaHallName, SizeRow = sizeRow, SizeColumn = sizeColumn
                };
                await unitOfWork.RepositoryInfrastructure.AddCinemaHallAsync(cinemaHall);

                cinemaHalls.Add(cinemaHall);

                Logger.Info($"Persisted cinema hall \"{cinemaHallName}\"");
            }

            var categories  = new[] { "Standard", "Premium", "Deluxe" };
            var categoryIds = (await ImportInfrastructureRowCategories(unitOfWork, categories)).ToList();

            foreach (var cinemaHall in cinemaHalls)
            {
                await ImportInfrastructureSeats(unitOfWork, cinemaHall.Id, categoryIds, cinemaHall.SizeRow,
                                                cinemaHall.SizeColumn);
            }
        }
コード例 #4
0
        public async Task <IActionResult> Edit(int id, [Bind("ID,Name,NumberOfSeats,ID_Cinema")] CinemaHall cinemaHall)
        {
            if (id != cinemaHall.ID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(cinemaHall);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CinemaHallExists(cinemaHall.ID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(cinemaHall));
        }
コード例 #5
0
        public async Task <ActionResult <CinemaHall> > PostCinemaHall(CinemaHall cinemaHall)
        {
            _context.cinemaHalls.Add(cinemaHall);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetCinemaHall", new { id = cinemaHall.cinemahallId }, cinemaHall));
        }
コード例 #6
0
        public async Task <bool> UpdateAsync(CinemaHall data)
        {
            if (data == null)
            {
                throw new ArgumentNullException(nameof(data));
            }

            var success = await this.dbContext.CinemaHallDao.UpdateAsync(data);

            if (success)
            {
                foreach (var row in data.Rows)
                {
                    if (row.RowId == 0)
                    {
                        await this.dbContext.RowDao.InsertAsync(data, row);
                    }

                    foreach (var seat in row.Seats)
                    {
                        if (seat.SeatId == 0)
                        {
                            await this.dbContext.SeatDao.InsertAsync(data, row, seat);
                        }
                    }
                }
            }

            return(await Task.FromResult(success));
        }
コード例 #7
0
        public async Task <int> UpdateCinemaHallAsync(CinemaHall cinemaHall)
        {
            ValidateNotNull(cinemaHall);
            await ValidateId(_cinemaHallDao, cinemaHall.Id);

            return(await _cinemaHallDao.FluentUpdate(cinemaHall).ExecuteAsync());
        }
コード例 #8
0
        public async Task <IActionResult> PutCinemaHall(int id, CinemaHall cinema)
        {
            if (id != cinema.cinemahallId)
            {
                return(BadRequest());
            }

            _context.Entry(cinema).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!CinemaHallExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
コード例 #9
0
        public async Task InsertAsyncTest()
        {
            const bool expectedStatus = true;

            var cinemaHall = new CinemaHall
            {
                Name = "MegaPlex",
                Rows = new List <Row>
                {
                    new Row
                    {
                        SeatCategory = new SeatCategory
                        {
                            SeatCategoryId = 1
                        },
                        Seats = new List <Seat>
                        {
                            new Seat(),
                            new Seat()
                        }
                    }
                }
            };

            var status = await cinemaHallLogic.InsertAsync(cinemaHall);

            Assert.Equal(expectedStatus, status);
            Assert.NotEqual(0, cinemaHall.CinemaHallId);
        }
コード例 #10
0
 public async Task <bool> DeleteAsync(CinemaHall item)
 {
     if (item == null || item.CinemaHallId <= 0)
     {
         throw new ArgumentException(nameof(item));
     }
     return(await dbContext.CinemaHallDao.DeleteAsync(item));
 }
コード例 #11
0
 public async Task <bool> UpdateAsync(CinemaHall data)
 {
     //UPDATE CinemaHall SET NAme = 'test', ARCHIVED = 1 WHERE CinemaHallId = 3
     return(await adoTemplate.ExecuteAsync(@"UPDATE CinemaHall SET Name = @CName, Archived = @Archive WHERE CinemaHallId = @CId",
                                           new QueryParameter(@"CName", data.Name),
                                           new QueryParameter(@"Archive", data.Archived),
                                           new QueryParameter(@"@CId", data.CinemaHallId)) == 1);
 }
コード例 #12
0
 public async Task <IEnumerable <Schedule> > FindByCinemaHallAsync(CinemaHall ch)
 {
     return(await adoTemplate.QueryAsync(@"SELECT * FROM Schedule
                                           INNER JOIN CinemaHall ON CinemaHall.CinemaHallId = Schedule.CinemaHallId
                                           INNER JOIN Movie ON Movie.MovieId = Schedule.MovieId 
                                           WHERE Schedule.CinemaHallId = @CId AND Movie.Archived = 0",
                                         MapRowToSchedule,
                                         new QueryParameter("@CId", ch.CinemaHallId)));
 }
コード例 #13
0
        public override object Clone()
        {
            var clone = (ScheduleMock)MemberwiseClone();

            clone.CinemaHall = (CinemaHallMock)CinemaHall?.Clone();
            clone.Movie      = (MovieMock)Movie?.Clone();
            clone.StartTime  = new DateTime(StartTime.Year, StartTime.Month, StartTime.Day, StartTime.Hour, StartTime.Minute, StartTime.Second, StartTime.Millisecond);
            return(clone);
        }
コード例 #14
0
      public ActionResult EditHallCinema(CinemaHall model, int halls)
      {
          model.HallId = halls;
          var entity = context.Entry(model);

          entity.State = System.Data.Entity.EntityState.Modified;
          context.SaveChanges();
          return(RedirectToAction("HallCinemaList"));
      }
コード例 #15
0
        public async Task DeleteAsyncTest()
        {
            var cinemaHall = new CinemaHall {
                CinemaHallId = 1, Name = "Test Entry"
            };
            var status = await cinemaHallLogic.DeleteAsync(cinemaHall);

            Assert.True(status);
        }
コード例 #16
0
        public async Task UpdateAsyncTest()
        {
            var cinemaHall = new CinemaHall {
                CinemaHallId = 1, Name = "Test Entry", Rows = new List <Row>()
            };
            var success = await this.cinemaHallLogic.UpdateAsync(cinemaHall);

            Assert.True(success);
        }
コード例 #17
0
        public async Task TestInsertAsync()
        {
            var cinema = new CinemaHall
            {
                Name = "My Special Cinema"
            };

            Assert.True(await adoDatabaseContext.CinemaHallDao.InsertAsync(cinema));
            Assert.NotZero(cinema.CinemaHallId);
        }
コード例 #18
0
 public async Task <IEnumerable <Seat> > FindByRowAndCinemaAsync(Row row, CinemaHall cinemaHall)
 {
     return(await adoTemplate.QueryAsync("SELECT * FROM Seat " +
                                         "INNER JOIN Row ON Row.RowId = Seat.RowId " +
                                         "INNER JOIN SeatCategory ON SeatCategory.SeatCategoryId = Row.SeatCategoryId " +
                                         "WHERE Seat.RowId = @RId AND Row.CinemaHallId = @CId",
                                         MapRowToSeat,
                                         new QueryParameter(@"@RId", row.RowId),
                                         new QueryParameter(@"@CId", cinemaHall.CinemaHallId)));
 }
コード例 #19
0
        public async Task <IActionResult> Create([Bind("ID,Name,NumberOfSeats,ID_Cinema")] CinemaHall cinemaHall)
        {
            if (ModelState.IsValid)
            {
                _context.Add(cinemaHall);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(cinemaHall));
        }
コード例 #20
0
        public async Task <long> AddCinemaHallAsync(CinemaHall cinemaHall)
        {
            ValidateNotNull(cinemaHall);
            if (await _cinemaHallDao.ExistByIdAsync(cinemaHall.Id))
            {
                var duplicateEntryException = new DuplicateEntryException(cinemaHall.Id, "CinemaHall already exists!");
                Logger.Error(duplicateEntryException, "{CinemaHall} already exists", cinemaHall);
                throw duplicateEntryException;
            }

            return((await _cinemaHallDao.FluentInsert(cinemaHall).ExecuteAsync()).First());
        }
コード例 #21
0
ファイル: Mapper.cs プロジェクト: EnvyIT/apollo
 public static CinemaHallDto Map(CinemaHall cinemaHall)
 {
     ValidateNull(Logger.Here(), cinemaHall);
     return(new CinemaHallDto
     {
         Id = cinemaHall.Id,
         RowVersion = cinemaHall.RowVersion,
         Label = cinemaHall.Label,
         SizeRow = cinemaHall.SizeRow,
         SizeColumn = cinemaHall.SizeColumn
     });
 }
コード例 #22
0
        public async Task <bool> AddProjections(ProjectionRes res)
        {
            try
            {
                Movie movie = await _dbContext.Movies.Where(m => m.Name == res.MovieName).FirstOrDefaultAsync();

                CinemaHall cinHall = await _dbContext.CinemaHalls.Where(m => m.Id == res.CinemaHallId).FirstOrDefaultAsync();



                Projection projection = new Projection
                {
                    ProjectionTime = res.ProjectionTime,
                    MovieId        = movie.Id,

                    CinemaHallId = cinHall.Id,
                };


                _dbContext.Add(projection);
                await _dbContext.SaveChangesAsync();

                Projection project = _dbContext.Projections.Where(m => m.ProjectionTime == res.ProjectionTime && m.MovieId == movie.Id).FirstOrDefault();

                List <AvailableSeatGetDetailsRes> avalSeats = await _dbContext.Seats
                                                              .Where(s => s.CinemaHallId == project.CinemaHallId)
                                                              .Select(avs => new AvailableSeatGetDetailsRes
                {
                    ProjectionId = project.Id,
                    SeatId       = avs.Id,
                    Name         = avs.Name
                }).ToListAsync();

                foreach (var avSeat in avalSeats)
                {
                    AvailableSeat availableSeat = new AvailableSeat
                    {
                        ProjectionId = avSeat.ProjectionId,
                        SeatId       = avSeat.SeatId
                    };

                    _dbContext.AvailableSeats.Add(availableSeat);
                    await _dbContext.SaveChangesAsync();
                }

                return(true);
            }
            catch
            {
                return(false);
            }
        }
コード例 #23
0
        public CinemaHallViewModel(ICinemaApi API)
        {
            _API = API;

            _timer          = new DispatcherTimer(DispatcherPriority.Normal);
            _timer.Interval = new TimeSpan(0, 5, 0);
            _timer.Tick    += _timer_Tick;
            _timer.Start();

            Hall          = CinemaHall.InitCinemaHall(colRows, colSeats);
            SelectedSeats = 0;
            GetMovies();
        }
コード例 #24
0
        public async Task <IEnumerable <Row> > FindByCinemaHallAsync(CinemaHall ch)
        {
            IEnumerable <Row> rows = await adoTemplate.QueryAsync(@"SELECT * FROM Row
                                                            INNER JOIN SeatCategory ON Row.SeatCategoryId = SeatCategory.SeatCategoryId
                                                            INNER JOIN CinemaHall ON CinemaHall.CinemaHallId = Row.CinemaHallId
                                                            WHERE Row.CinemaHallId = @CId",
                                                                  MapRowToRow,
                                                                  new QueryParameter("@CId", ch.CinemaHallId));

            ch.Rows = rows;

            return(rows);
        }
コード例 #25
0
        public Task <bool> InsertAsync(CinemaHall item, Row row, Seat seat)
        {
            if (seat == null)
            {
                throw new ArgumentNullException(nameof(seat));
            }
            seat.CinemaHall = item ?? throw new ArgumentNullException(nameof(item));
            seat.Row        = row ?? throw new ArgumentNullException(nameof(row));

            this.mockedSeats.Add(seat);

            return(Task.FromResult(true));
        }
コード例 #26
0
        public async Task <IEnumerable <Row> > FindAllAsync(CinemaHall hall)
        {
            var rows = await dbContext.RowDao.FindByCinemaHallAsync(hall);

            foreach (var row in rows)
            {
                row.SeatCategory = await dbContext.SeatCategoryDao.FindByIdAsync(row.SeatCategory.SeatCategoryId);

                row.Seats = await dbContext.SeatDao.FindByRowAndCinemaAsync(row, hall);
            }

            return(rows);
        }
コード例 #27
0
        void dużaToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            średniaToolStripMenuItem.Checked = false;
            małaToolStripMenuItem.Checked    = false;
            size = CinemaHall.Big;
            dużaToolStripMenuItem1.Checked = true;
            boardWidth  = 20;
            boardHeight = 20;
            roomName    = "Duża";

            screenLoad();
            loadCinemaHallFromFile("duza");
        }
コード例 #28
0
        void średniaToolStripMenuItem_Click(object sender, EventArgs e)
        {
            dużaToolStripMenuItem1.Checked = false;
            małaToolStripMenuItem.Checked  = false;
            size = CinemaHall.Medium;
            średniaToolStripMenuItem.Checked = true;
            boardWidth  = 10;
            boardHeight = 15;
            roomName    = "Średnia";

            screenLoad();
            loadCinemaHallFromFile("srednia");
        }
コード例 #29
0
        void małaToolStripMenuItem_Click(object sender, EventArgs e)
        {
            średniaToolStripMenuItem.Checked = false;
            dużaToolStripMenuItem1.Checked   = false;
            size = CinemaHall.Small;
            małaToolStripMenuItem.Checked = true;
            boardWidth  = 10;
            boardHeight = 10;
            roomName    = "Mała";

            screenLoad();
            loadCinemaHallFromFile("mala");
        }
コード例 #30
0
        public CinemaHall GetCinemaHall(int cinema_id, int cinemahall_id)
        {
            CinemaHall cinemaHall = null;

            using (var conn = new SqlConnection(connectionStr))
            {
                var cmd = new SqlCommand();
                try
                {
                    cmd.Connection  = conn;
                    cmd.CommandType = CommandType.Text;
                    cmd.CommandText = @"select 
                        ch.Name as 'CinemaHallName' 
                        , c.Name as 'CinemaName'
						, ch.Schema_Url 
                        from CinemaHalls as ch
                        join Cinemas as c 
                        on ch.CinemaId = c.Id
                        where ch.Id = @Id and ch.CinemaId = @CinemaId";
                    var cinemaId     = new SqlParameter("@CinemaId", cinema_id);
                    var cinemaHallId = new SqlParameter("@Id", cinemahall_id);
                    cmd.Parameters.Add(cinemaId);
                    cmd.Parameters.Add(cinemaHallId);
                    cmd.Connection.Open();
                    var reader = cmd.ExecuteReader();

                    while (reader.Read())
                    {
                        cinemaHall = new CinemaHall
                        {
                            Id       = cinemahall_id,
                            CinemaId = cinema_id,
                            Cinema   = new Cinema
                            {
                                Id      = cinema_id,
                                Name    = (string)reader["CinemaName"],
                                Address = reader.IsDBNull(reader.GetOrdinal("Address")) ? string.Empty : (string)reader["Address"]
                            },
                            Name       = (string)reader["CinemaHallName"],
                            Schema_Url = (string)reader["Schema_Url"]
                        };
                    }
                }
                catch (Exception)
                {
                    throw;
                }
            }
            return(cinemaHall);
        }