public ActionResult <Entity> Delete(int id)
        {
            try
            {
                GetFindFlightCommand _idFlight = CommandFactory.GetFlightIdCommand((int)id);
                _idFlight.Execute();

                if (_idFlight.Equals(null))
                {
                    throw new ValidationErrorException("El vuelo que quiere borrar no existe");
                }

                DeleteFlightCommand _iddelet = CommandFactory.DeleteFlightCommand(_idFlight.GetResult());
                _iddelet.Execute();

                return(Ok(new { Message = "¡Vuelo borrado con éxito!" }));
            }
            catch (ValidationErrorException ex)
            {
                return(BadRequest(new { Message = ex.Message }));
            }
            catch (DbErrorException ex)
            {
                return(BadRequest(new { Message = ex.Message }));
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
                return(null);
            }
            //return Ok(id);
        }
Esempio n. 2
0
 public GenericCommandResult Delete(
     [FromBody] DeleteFlightCommand command,
     [FromServices] FlightHandler handler
     )
 {
     return((GenericCommandResult)handler.Handle(command));
 }
Esempio n. 3
0
 public ICommandResult Handle(DeleteFlightCommand command)
 {
     command.Validate();
     if (command.Invalid)
     {
         return(new GenericCommandResult(false, "Ops, this flight is wrong!", command.Notifications));
     }
     _repository.Delete(command.Id);
     return(new GenericCommandResult(true, "Flight Deleted!", null));
 }
        //[Route("api/ClubFlight/Delete")]
        //[HttpPut("{id}", Name = "Delete")]
        public async Task Delete([FromBody] int id)
        {
            if (ModelState.IsValid)
            {
                System.Diagnostics.Debug.WriteLine(id.ToString());
                DeleteFlightCommand deleteFlightCommand = new DeleteFlightCommand(id);
                var result = await _mediator.Send(deleteFlightCommand);

                return;
            }
        }
Esempio n. 5
0
        public async Task <IActionResult> Delete(int id)
        {
            DeleteFlightCommand deleteFlightCommand = new DeleteFlightCommand()
            {
                Id = id
            };

            await _mediator.Send(deleteFlightCommand);

            ClearCache();

            return(NoContent());
        }
Esempio n. 6
0
 public async Task <IActionResult> DeleteById([FromBody] DeleteFlightCommand command)
 => Ok((await m_Mediator.Send(command)));