public HttpResponseMessage Delete(int id) { var cheque = _chequeRepository.Get(id); if (cheque == null) { return(Request.CreateResponse(HttpStatusCode.NotFound, new BaseApiResponse { Code = InternalApiStatusCode.Error, Message = "cheque item is not found" })); } try { _chequeRepository.Remove(id); return(Request.CreateResponse(HttpStatusCode.OK, new BaseApiResponse { Code = InternalApiStatusCode.Success, Message = "cheque item removed" })); } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex)); } }
public Task <CommandResult> Handle(RemoveChequeCommand command, CancellationToken cancellationToken) { if (!command.IsValid()) { NotifyCommandErrors(command); return(Response()); } Cheque cheque = _chequeRepository.GetById(command.Id); _chequeRepository.Remove(cheque); if (Commit()) { _mediator.Publish(new RemovedChequeEvent()); } return(Response()); }