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());
        }
Exemple #2
0
        public async Task <IActionResult> DeleteConfirmed(int id)
        {
            await _service.Delete(id);

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

            return(RedirectToAction(nameof(Index)));
        }
        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());
        }
Exemple #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());
 }
Exemple #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));
        }
Exemple #9
0
 public IActionResult DeleteConfirmed(int id)
 {
     _flightService.Delete(id);
     return(RedirectToAction(nameof(Index)));
 }
Exemple #10
0
 public void Delete(int id)
 {
     _flightService.Delete(id);
 }
 public void Delete()
 {
     service.Delete();
 }
Exemple #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"));
 }