示例#1
0
 public EstabelecimentosController(IEstabelecimentoReadOnlyRepository estabelecimentoReadOnlyRepository,
                                   IMediator mediator,
                                   IMapper mapper)
 {
     this.estabelecimentoReadOnlyRepository = estabelecimentoReadOnlyRepository ?? throw new ArgumentNullException(nameof(estabelecimentoReadOnlyRepository));
     this.mediator = mediator ?? throw new ArgumentNullException(nameof(mediator));
     this.mapper   = mapper ?? throw new ArgumentNullException(nameof(mapper));
 }
示例#2
0
 public CriarEstabelecimentoCommandHandler(IUserPrincipalBuilder userPrincipalBuilder,
                                           IEstabelecimentoReadOnlyRepository estabelecimentoReadOnlyRepository,
                                           IEstabelecimentoWriteOnlyRepository estabelecimentoWriteOnlyRepository,
                                           IAuditTrailProvider auditTrailProvider)
 {
     this.userPrincipalBuilder = userPrincipalBuilder ?? throw new ArgumentNullException(nameof(userPrincipalBuilder));
     this.estabelecimentoReadOnlyRepository  = estabelecimentoReadOnlyRepository ?? throw new ArgumentNullException(nameof(estabelecimentoReadOnlyRepository));
     this.estabelecimentoWriteOnlyRepository = estabelecimentoWriteOnlyRepository ?? throw new ArgumentNullException(nameof(estabelecimentoWriteOnlyRepository));
     this.auditTrailProvider = auditTrailProvider ?? throw new ArgumentNullException(nameof(auditTrailProvider));
 }
        public async Task <IActionResult> EstabelecimentosDeleteAsync(Guid id,
                                                                      Guid estabelecimentoId,
                                                                      [FromServices] IEstabelecimentoReadOnlyRepository estabelecimentoReadOnlyRepository)
        {
            var cipa = await ObterCipaAsync(id);

            var estabelecimento = await estabelecimentoReadOnlyRepository.GetByIdAsync(estabelecimentoId) ??
                                  throw new ResourceNotFoundException(new CoreBusinessResourceNotFoundExceptionItem[] { CoreBusinessResourceNotFoundExceptionItem.Estabelecimento });

            var command = new AtualizarEstabelecimentoCommand()
            {
                Estabelecimento = estabelecimento,
                Codigo          = estabelecimento.Codigo,
                Nome            = estabelecimento.Nome,
                CipaId          = null
            };

            await mediator.Send(command);

            return(NoContent());
        }