public IHttpActionResult Post(FlightRequest flight)
        {
            if (_flightService.Query().Any(f => f.To.AirportCode == flight.To.Airport &&
                                           f.To.City == flight.To.City && f.To.Country == flight.To.Country &&
                                           f.From.AirportCode == flight.From.Airport &&
                                           f.From.City == flight.From.City &&
                                           f.From.Country == flight.From.Country &&
                                           f.ArrivalTime == flight.ArrivalTime &&
                                           f.DepartureTime == flight.DepartureTime &&
                                           f.Carrier == flight.Carrier))
            {
                Flight userFlight = _flightService.Query().FirstOrDefault(f => f.To.AirportCode == flight.To.Airport &&
                                                                          f.To.City == flight.To.City && f.To.Country == flight.To.Country &&
                                                                          f.From.AirportCode == flight.From.Airport &&
                                                                          f.From.City == flight.From.City &&
                                                                          f.From.Country == flight.From.Country &&
                                                                          f.ArrivalTime == flight.ArrivalTime &&
                                                                          f.DepartureTime == flight.DepartureTime &&
                                                                          f.Carrier == flight.Carrier);

                _flightService.Delete(userFlight);
            }

            return(Ok());
        }
Esempio n. 2
0
        public async Task <IActionResult> DeleteConfirmed(int id)
        {
            await _service.Delete(id);

            await _signalrHub.Clients.All.SendAsync("LoadFlights");

            return(RedirectToAction(nameof(Index)));
        }
Esempio n. 3
0
        public async Task<ActionResult> Delete(int id)
        {
            var success = await _flightService.Delete(id);
            if (success)
            {
                return Ok();
            }

            return BadRequest();
        }
        public IActionResult Delete(int id)
        {
            bool result = service.Delete(id);

            if (!result)
            {
                return(NotFound());
            }

            return(NoContent());
        }
Esempio n. 5
0
        public async Task <IActionResult> Delete(int id)
        {
            bool result = await service.Delete(id);

            if (!result)
            {
                return(NotFound());
            }

            return(NoContent());
        }
 public async Task <IActionResult> Delete(int id)
 {
     try
     {
         await service.Delete(id);
     }
     catch (ValidationException e)
     {
         return(BadRequest(new { Exception = e.Message }));
     }
     return(NoContent());
 }
Esempio n. 7
0
        public IActionResult Delete(Guid id)
        {
            try
            {
                flightService.Delete(id);
            }
            catch (Exception ex)
            {
                return(BadRequest(new { Type = ex.GetType().Name, ex.Message }));
            }

            return(NoContent());
        }
        public async Task <ActionResult <FlightViewModel> > Delete(Guid id)
        {
            var flight = await _flightService.GetById(id);

            if (flight == null)
            {
                _logger.LogInformation($"Flight id = {id} not found.");
                return(NotFound());
            }

            await _flightService.Delete(flight);

            return(Ok(flight));
        }
Esempio n. 9
0
 public IActionResult DeleteConfirmed(int id)
 {
     _flightService.Delete(id);
     return(RedirectToAction(nameof(Index)));
 }
Esempio n. 10
0
 public void Delete(int id)
 {
     _flightService.Delete(id);
 }
Esempio n. 11
0
 public void Delete()
 {
     service.Delete();
 }
Esempio n. 12
0
        public async Task <IActionResult> Delete(int id)
        {
            await _service.Delete(id);

            return(NoContent());
        }
 public IActionResult DeleteConfirm(int id)
 {
     flightService.Delete(id);
     return(Redirect("/Flight/All"));
 }