コード例 #1
0
        public async Task <ActionResult> Post(CreateCinemaRequest model)
        {
            Guid cinemaId = Guid.NewGuid();
            await _cinemaService.Add(cinemaId, model);

            return(CreatedAtRoute(nameof(GetCinemaById), new { id = cinemaId }, cinemaId));
        }
コード例 #2
0
        public async Task Add(Guid id, CreateCinemaRequest request)
        {
            Cinema cinema = CinemaFactory.Create(id, request.Name, request.City);

            _ctx.Add(cinema);
            await _ctx.SaveChangesAsync();
        }
コード例 #3
0
        public async Task <IActionResult> CreateAsync(CreateCinemaRequest request, CancellationToken token)
        {
            _logger.LogInformation("POST /cinema request accepted");
            var response = await _cinemaService.CreateAsync(_mapper.Map <CinemaDTO>(request));

            return(Ok(_mapper.Map <CinemaResponse>(response)));
        }
コード例 #4
0
        public async Task GivenCinemaInIsDefined(string cinema, string city)
        {
            CreateCinemaRequest request = new CreateCinemaRequest()
            {
                Name = cinema,
                City = city
            };
            HttpResponseMessage response = await Client.PostAsJsonAsync("/api/cinemas/", request);

            _createdCinemaId = GetGuidFromLocationHeader(response);
        }
コード例 #5
0
        public ActionResult CreateCinema([FromBody] CreateCinemaRequest cinema)
        {
            //if (!ActiveStatus.ActiveUser.IsAdmin)
            //    return this.BadRequest();

            try
            {
                this.cinemaService.Add(cinema.Caption, cinema.Address, cinema.CinemaNetworkId, cinema.City, cinema.Description, cinema.Email, cinema.PhoneNumber);
            }
            catch (Exception exception)
            {
                return(this.BadRequest(exception.Message));
            }

            return(this.Ok(cinema));
        }