private async Task <bool> ProcessDemandAsync(string message, string action)
        {
            switch (action)
            {
            case "create":

                break;

            case "update":

                break;

            case "delete":
                var id = JsonConvert.DeserializeObject <string>(message);

                var offers = await _repository.GetOffersByDemandID(id);

                foreach (var offer in offers)
                {
                    await _repository.Delete(offer.Id);
                }

                break;

            default:
                break;
            }
            return(true);
        }
        public async Task <IActionResult> Delete(int id)
        {
            var location = GetControllerActionNames();

            try
            {
                _logger.LogInfo($"{location}: Delete Attempted on record with id: {id} ");
                if (id < 1)
                {
                    _logger.LogWarn($"{location}: Delete failed with bad data - id: {id}");
                    return(BadRequest());
                }
                var isExists = await _offerRepository.isExists(id);

                if (!isExists)
                {
                    _logger.LogWarn($"{location}: Failed to retrieve record with id: {id}");
                    return(NotFound());
                }
                var offer = await _offerRepository.FindById(id);

                var isSuccess = await _offerRepository.Delete(offer);

                if (!isSuccess)
                {
                    return(InternalError($"{location}: Delete failed for record with id: {id}"));
                }
                _logger.LogInfo($"{location}: Record with id: {id} successfully deleted");
                return(NoContent());
            }
            catch (Exception e)
            {
                return(InternalError($"{location}: {e.Message} - {e.InnerException}"));
            }
        }
        public async Task <IActionResult> DeleteVehicleById(string id)
        {
            this.PublishEvent("delete", "company.offer", id: id);
            this.PublishEvent("delete", "customer.offer", id: id);
            this.PublishEvent("delete", "demand.offer", id: id);

            return(Ok(await _repository.Delete(id)));
        }
Beispiel #4
0
        public void DeleteOffer(int id)
        {
            Offer offer = _offerRepository.Find(id);

            if (offer != null)
            {
                _offerRepository.Delete(offer);
            }
        }
        public IActionResult Delete(long id)
        {
            var offer = repository.ReadId(id);

            if (offer != null)
            {
                repository.Delete(offer);
                return(Ok());
            }
            return(NotFound());
        }
Beispiel #6
0
        //CRUD

        public override ProcessResult Delete(int id)
        {
            try
            {
                _repository.Delete(id);
                return(ServiceResultsHelper.FillProcessResult(null));
            }
            catch (Exception ex)
            {
                return(ServiceResultsHelper.FillProcessResultForError(ex));
            }
        }
        public async Task <bool> Handle(DeleteOfferCommand request, CancellationToken cancellationToken)
        {
            Offer offer = await _offerRepository.GetByIdAsync(request.Id);

            if (offer == null)
            {
                throw new ApiException("The offer can't be found", StatusCodes.Status404NotFound);
            }

            _offerRepository.Delete(offer);

            return(await _offerRepository.UnitOfWork.SaveEntitiesAsync());
        }
Beispiel #8
0
 public void Delete(short id)
 {
     try
     {
         _offerRepository.Delete(id);
         _offerRepository.SaveChanges();
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
         throw;
     }
 }
Beispiel #9
0
        public bool Delete(int id)
        {
            var quer = _repo.GetById(id);

            if (quer == null)
            {
                return(false);
            }
            _repo.Delete(id);
            _repo.SaveChanges();

            return(true);
        }
Beispiel #10
0
        public async Task <bool> DeleteOffer(Guid id)
        {
            try
            {
                var offer = await GetOfferById(id);

                _offerRepository.Delete(offer);
                await _offerRepository.SaveAsync();

                return(true);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.ToString());
            }
        }
Beispiel #11
0
        public void DeleteOffer(OfferViewModel model)
        {
            var entity = repository.FindByCondition(x => x.OfferId == model.OfferId).FirstOrDefault();

            repository.Delete(entity);
        }
Beispiel #12
0
 public Task DeleteOffer(int Id)
 {
     return(_offerRepository.Delete(Id));
 }
Beispiel #13
0
        //public async Task<Offer> GetOfferAsync(int id)
        //{
        //    var offer = await offersRepository.GetAsync(o => o.Id == id);
        //    return offer;
        //}

        public void Delete(Offer offer)
        {
            offersRepository.Delete(offer);
        }
Beispiel #14
0
 public void DeleteOffer(Offer offer)
 {
     _offerRepository.Delete(offer);
 }
Beispiel #15
0
 public async Task Consume(ConsumeContext <ListingDeletedMessage> context)
 {
     var message = context.Message.ListingId;
     await offerRepository.Delete(message);
 }