Пример #1
0
 public async Task <ApiError> DeleteAsync(OfferModel model)
 {
     if (model is null)
     {
         return(new(Strings.InvalidModel));
     }
     try
     {
         return(ApiError.FromDalResult(await _offerRepository.DeleteAsync(model.Id)));
     }
     catch (Exception ex)
     {
         return(ApiError.FromException(ex));
     }
 }
        public async Task <IActionResult> Delete(int id)
        {
            Offer existing = await offerRepository.FindByIdAsync(id);

            if (existing == null)
            {
                return(NotFound());
            }

            bool deleted = await offerRepository.DeleteAsync(existing);

            if (deleted)
            {
                return(new OkResult());
            }

            return(BadRequest());
        }
Пример #3
0
        public async Task <IOperationResult> HandleAsync(IDeleteOffer command, ICorrelationContext context)
        {
            if (command == null)
            {
                throw new ArgumentNullException(nameof(command));
            }

            var offer = await _repository.GetAsync(command.Id);

            if (offer is null)
            {
                throw new BaristaException("offer_not_found", $"Could not find offer with ID '{command.Id}'");
            }

            await _repository.DeleteAsync(offer);

            await _repository.SaveChanges();

            await _busPublisher.Publish(new OfferDeleted(offer.Id));

            return(OperationResult.Ok());
        }
Пример #4
0
 public Task <object> DeleteAsync(long id)
 {
     return(_offerRepository.DeleteAsync(id));
 }