示例#1
0
        public async Task <ActionResult> Put([FromBody] FlightScheduleRequest flightRequest, CancellationToken cancellationToken)
        {
            var result = await _flightAppSchedule.ReplaceFlightAsync(flightRequest, cancellationToken);

            return(result.StatusCode.IsSuccessStatusCode()
                ? new OkObjectResult(result.Value)
                : StatusCode((int)result.StatusCode, GenerateProblemsDetail(result)));
        }
示例#2
0
        public async Task <ActionResult> Post([FromBody] FlightScheduleRequest flightRequest, CancellationToken cancellationToken)
        {
            var result = await _flightAppSchedule.CreateFlightAsync(flightRequest, cancellationToken);

            return(result.StatusCode.IsSuccessStatusCode()
                ? new CreatedResult($"{Request.Host.Value}{Request.Path.Value}/{result.Value}", new { id = result.Value })
                : StatusCode((int)result.StatusCode, GenerateProblemsDetail(result)));
        }
        public async void AddOne_NullValue_ReturnsError()
        {
            FlightScheduleRequest flightRequest = null;

            var result = await _flightScheduleService.CreateAsync(flightRequest, _cancellationToken);

            Assert.True(result.StatusCode == HttpStatusCode.BadRequest);
            Assert.True(result.ProblemTittle == "Object is null");
        }
        public async void AddOne_NullOrWhiteSpaceName_ReturnsError()
        {
            var flightRequest = new FlightScheduleRequest()
            {
                DataHoraPartida = Convert.ToDateTime("08/03/2020 18:46"),
                Destino         = "Recife",
                Origem          = "São Paulo",
                Nome            = " "
            };

            var flight = new FlightScheduleModel()
            {
                Id = "werogninerpgnperiogn",
                DataHoraPartida = Convert.ToDateTime("08/03/2020 18:46"),
                Destino         = "Recife",
                Origem          = "São Paulo",
                Nome            = " "
            };

            _mapper.Map <FlightScheduleRequest, FlightScheduleModel>(default)
 public async Task <Result <long> > ReplaceAsync(FlightScheduleRequest flightRequest, CancellationToken cancellationToken)
 {
     return(await this.ReplaceOneAsync(flightRequest, cancellationToken));
 }
 public async Task <Result <string> > CreateAsync(FlightScheduleRequest flightRequest, CancellationToken cancellationToken)
 {
     return(await this.AddAsync <FlightScheduleRequest>(flightRequest, cancellationToken));
 }
 public async Task <Result <string> > CreateFlightAsync(FlightScheduleRequest flightRequest, CancellationToken cancellationToken)
 {
     return(await _flightScheduleService.CreateAsync(flightRequest, cancellationToken));
 }