public void DeleteDistributor(DeleteDistributorInput input) { var distributor = _DistributorRepository.Get(input.Id); distributor.IsDeleted = true; _DistributorRepository.Delete(distributor); }
public async Task Remove(int id) { var distributor = await Get(id); if (distributor == null) { throw new NotFoundException("Distributor não encontrado", id); } await _repository.Delete(distributor); }
public IActionResult Delete(long id) { var Distributor = _repo.Find(id); if (Distributor == null) { return(NotFound()); } _repo.Delete(Distributor); return(Ok()); }
public void Remove(int distributorId) { Distributor d = repository.GetById(distributorId); if (d == null) { return; } repository.Delete(d); repository.CommitChange(); ControllerManager.PriceList.CalculateDiscounts(d.PriceList); CacheManager.ExpireAll(typeof(Distributor)); }
public async Task <Unit> Handle(DeleteDistributorCommand request, CancellationToken cancellationToken) { // get distributor by id var distributorFromRepo = await _distributorRepository.FindByIdAsync(request.DistributorId); if (distributorFromRepo == null) { throw new DistributorNotFoundException(request.DistributorId); } if (distributorFromRepo.DistributorUsers.Count > 0) { throw new DistributorContainsUsersException(request.DistributorId); } // update distributor with the deleted _distributorRepository.Delete(distributorFromRepo); // save changes in the database and rase DistributorUpdated event await _distributorRepository.UnitOfWork.SaveEntitiesAsync(cancellationToken); return(MediatR.Unit.Value); }
public void DeleteDistributor(Guid distributorId) { distributorRepository.Delete(dist => dist.UserId == distributorId); }