Пример #1
0
 public InvoiceEntry CreateInvoiceEntry(AddInvoiceEntryModel model)
 {
     try
     {
         var newInvoiceEntry = _invoiceRepository.CreateNewInvoiceEntry(model);
         return(newInvoiceEntry);
     }
     catch (Exception)
     {
         // TODO: Log the exception
         return(null);
     }
 }
Пример #2
0
        public InvoiceEntry CreateNewInvoiceEntry(AddInvoiceEntryModel model)
        {
            var newInvoiceEntry = new InvoiceEntry
            {
                Amount       = model.Amount,
                CreationDate = model.CreationDate,
                InvoiceId    = model.InvoiceId,
                Subject      = model.Subject
            };

            _dbContext.Add(newInvoiceEntry);

            _dbContext.SaveChanges();

            return(newInvoiceEntry);
        }
        public IActionResult AddInvoiceEntry([FromBody] AddInvoiceEntryModel model)
        {
            if (model == null)
            {
                return(BadRequest());
            }

            var createdInvoiceEntry = _manager.CreateInvoiceEntry(model);

            if (createdInvoiceEntry != null)
            {
                //return Created(nameof(GetById), createdInvoiceEntry);
                // TODO: Make a getbyid action
                return(Created("test", createdInvoiceEntry));
            }

            return(StatusCode(500));
        }