Пример #1
0
        public static FlightReservationUpdateCommandBuilder Start()
        {
            _command = new FlightReservationUpdateCommand()
            {
                Id              = 1,
                InputDate       = DateTime.Now,
                OutputDate      = DateTime.Now.AddDays(10),
                FlightCustomers = new List <CustomerUpdateCommand>()
                {
                    PassengerUpdateCommandBuilder.Start().Build()
                }
            };

            return(new FlightReservationUpdateCommandBuilder());
        }
        public void UpdateFlightReservation_IntegrationTest()
        {
            var flightCmd = new FlightReservationUpdateCommand()
            {
                Id         = 1,
                OutputDate = DateTime.Now.AddDays(20).Date,
            };
            var myContent     = JsonConvert.SerializeObject(flightCmd);
            var stringContent = new StringContent(myContent, UnicodeEncoding.UTF8, "application/json");

            var httpResponse = _client.PutAsync($"{_url}", stringContent).Result;

            httpResponse.EnsureSuccessStatusCode();

            CustomWebApplicationFactory <Startup> .appDb.FlightReservation.Find(1);
        }
Пример #3
0
        public async Task <IActionResult> UpdateFlight(int id)
        {
            var flightCmd = new FlightReservationUpdateCommand()
            {
                Id              = id,
                InputDate       = DateTime.Now.AddDays(10),
                OutputDate      = DateTime.Now.AddDays(10),
                FlightCustomers = new List <CustomerUpdateCommand>()
                {
                    new CustomerUpdateCommand()
                    {
                        Name = "Roberto", LastName = "Bola", Sex = SexEnum.Male
                    }
                }
            };

            var myContent     = JsonConvert.SerializeObject(flightCmd);
            var stringContent = new StringContent(myContent, UnicodeEncoding.UTF8, "application/json");

            await client.PutAsync($"https://localhost:44301/api/flights/{id}", stringContent);

            return(Ok());
        }