Exemplo n.º 1
0
        public async Task <ActionResult> AddShow(Guid id, CreateShowRequest model)
        {
            Guid showId = Guid.NewGuid();
            await _cinemaService.AddShow(id, showId, model);

            return(CreatedAtRoute(nameof(ShowsController.GetShowById), new { id = showId }, showId));
        }
Exemplo n.º 2
0
 public IActionResult CreateShow(CreateShowRequest request)
 {
     if (ModelState.IsValid)
     {
         var show = new Show
         {
             DateTime      = request.Date,
             MovieId       = request.Movie,
             Price         = request.Price,
             PriceInPoints = request.PriceInPoints,
             RoomId        = request.Room,
             ShowId        = Guid.NewGuid().ToString()
         };
         AdministrationRepository.AddShow(show);
         return(RedirectToAction("GetShows"));
     }
     foreach (var error in ModelState.Values)
     {
         foreach (var item in error.Errors)
         {
             Logger.LogError(item.ErrorMessage);
         }
     }
     return(View("Getshows"));
 }
Exemplo n.º 3
0
        public async Task AddShow(Guid cinemaId, Guid showId, CreateShowRequest request)
        {
            Cinema cinema = await _ctx.Cinemas.Include(c => c.Shows).FirstOrDefaultAsync(c => c.Id == cinemaId);

            Movie movie = await _ctx.Movies.FindAsync(request.MovieId);

            Dictionary <Ticket, decimal> priceList = request.PriceList.ToDictionary(x => x.Kind, x => x.Price);
            Show show = ShowFactory.Create(showId, cinema, movie, request.Date, priceList);

            cinema.AddShow(show);
            await _ctx.SaveChangesAsync();
        }
Exemplo n.º 4
0
        public void CreateShowRequestTest()
        {
            CreateShowRequest request = new CreateShowRequest()
            {
                Movie         = "TestMovie",
                Date          = DateTime.Today,
                Price         = 1,
                PriceInPoints = 1,
                Room          = "TestRoom"
            };

            IActionResult createShow = administration.CreateShow(request);

            Assert.IsType <RedirectToActionResult>(createShow);
        }
        public async Task GivenShowIsPlayedInCinemaInOnWithTicketPriceOfPLN(string movie, string cinema, string city, string datetime, int price)
        {
            CreateShowRequest request = new CreateShowRequest()
            {
                MovieId   = _createdMovieId,
                Date      = DateTime.Now.AddMinutes(60),
                PriceList = new List <TicketPrice>
                {
                    new TicketPrice
                    {
                        Kind  = Ticket.Normal,
                        Price = price
                    }
                }
            };
            HttpResponseMessage response = await Client.PostAsJsonAsync($"/api/cinemas/{_createdCinemaId}/shows", request);

            _createdShowId = GetGuidFromLocationHeader(response);
        }
Exemplo n.º 6
0
        public async Task <ActionResult> Post(CreateShowRequest model)
        {
            Guid guid = Guid.NewGuid();

            return(CreatedAtRoute(nameof(GetShowById), new { id = guid }, guid));
        }