Example #1
0
        public async Task <IActionResult> AddDatiPagamento(DatiPagamentoModel dp)
        {
            var res = await InvService.AddAsync(dp).ConfigureAwait(false);

            if (res.Count > 0)
            {
                return(Ok(res));
            }
            else
            {
                return(BadRequest());
            }
        }
Example #2
0
        public async Task <IActionResult> AddInvoiceAsync([FromBody] Invoice invoice)
        {
            try
            {
                _logger.LogDebug("Inserting new Invoice");
                bool success = await _invoiceService.AddAsync(invoice);

                if (success)
                {
                    _logger.LogDebug("Invoice inserted successfully");
                    return(Ok("Invoice created successfully"));
                }
                else
                {
                    _logger.LogDebug("Invoice insert failed. Duplicate invoice found");
                    return(Conflict("Duplicate Invoice"));
                }
            }
            catch (Exception ex)
            {
                //log
                _logger.LogError("Add invoice failed. An exception occured: {ex}", ex.Message);
                _logger.LogError("Stack Trace: {ex}", ex.StackTrace);
                return(BadRequest());
            }
        }