Beispiel #1
0
        public async Task <ValidationResult> Handle(RemoveConvenioCommand request, CancellationToken cancellationToken)
        {
            if (!request.IsValid())
            {
                return(request.ValidationResult);
            }

            var convenio = await _convenioRepository.GetById(request.Id);

            if (convenio is null)
            {
                AddError("Convênio não existe");
                return(ValidationResult);
            }

            convenio.AddDomainEvent(new ConvenioRemovedEvent(request.Id));

            _convenioRepository.Remove(convenio);

            return(await Commit(_convenioRepository.UnitOfWork));
        }
Beispiel #2
0
 public async Task <ConvenioViewModel> GetById(Guid id) =>
 _mapper.Map <ConvenioViewModel>(await _convenioRepository.GetById(id));
 public Convenio Get(int id) => _repository.GetById(id);