Exemplo n.º 1
0
        public IActionResult GetAllUsuarios()
        {
            _metricsRegistry.IncrementFindQuery();
            _logger.LogInformation("Get Security(Auth)");
            var usuarios = _accessService.GetAll();

            return(Ok(usuarios));
        }
Exemplo n.º 2
0
        public async Task <IActionResult> GetHistory(int idinvoice)
        {
            _metricsRegistry.IncrementFindQuery();
            _logger.LogInformation("Get History {idinvoice} ");
            string _key = $"key-invoice-{idinvoice}";

            var _cache = _distributedCache.GetString(_key);
            List <HistoryResponse> model = null;

            if (_cache == null)
            {
                var result = await _historyService.GetAll();

                model = result.Where(x => x.Idinvoice.Equals(idinvoice)).ToList();

                var options = new DistributedCacheEntryOptions()
                              .SetSlidingExpiration(TimeSpan.FromSeconds(30));
                _distributedCache.SetString(_key, Newtonsoft.Json.JsonConvert.SerializeObject(model), options);
            }
            else
            {
                model = Newtonsoft.Json.JsonConvert.DeserializeObject <List <HistoryResponse> >(_cache);
            }
            return(Ok(model));
        }
Exemplo n.º 3
0
        public IActionResult GetNotification(int id)
        {
            _logger.LogInformation("Get Notification");
            _metricsRegistry.IncrementFindQuery();
            var entity = _mailRepository.GetAll();

            return(Ok(entity));
        }
Exemplo n.º 4
0
        public ActionResult GetAllInvoice()
        {
            _metricsRegistry.IncrementFindQuery();
            _logger.LogInformation("Get Invoice");
            var invoices = _invoiceService.GetAll().OrderBy(x => x.IdInvoice);

            return(Ok(invoices));
        }
Exemplo n.º 5
0
        public IActionResult Pagos([FromBody] InvoiceRequest request)
        {
            _metricsRegistry.IncrementFindQuery();
            _logger.LogInformation("Post Pay(Pagos)");

            Model.Transaction transaction = new Model.Transaction()
            {
                IdInvoice = request.IdInvoice,
                Amount    = request.Amount,
                Date      = DateTime.Now.ToString()
            };
            transaction = _transactionService.Pay(transaction);

            bool isProccess = _invoiceService.Execute(transaction);

            if (isProccess)
            {
                var createCommad = new TransactionPayCreatedCommand(
                    idOperation: transaction.IdOperation,
                    amount: transaction.Amount,
                    date: transaction.Date,
                    idInvoice: transaction.IdInvoice
                    );
                _bus.SendCommand(createCommad);

                var createdInvoice = new InvoiceCreatedCommand(
                    idInvoice: transaction.IdInvoice,
                    amount: transaction.Amount,
                    state: "PAGADO"
                    );

                _bus.SendCommand(createdInvoice);

                var createCommadNotification = new NotificationCreateCommand(
                    idOperation: transaction.IdOperation,
                    idInvoice: transaction.IdInvoice,
                    amount: transaction.Amount);

                _bus.SendCommand(createCommadNotification);
            }

            return(Ok(transaction));
        }
Exemplo n.º 6
0
 public IActionResult Get()
 {
     _metricsRegistry.IncrementFindQuery(); //ACA ESTAMOS REGISTRANDO METRICAS DE NUESTRO METODO GET
     _logger.LogInformation("Get Account");
     return(Ok(_accountService.GetAll()));
 }