public ActionResult Create(InvoiceDTO invoice) { try { CustomerDTO customer = new CustomerDTO(); InvoiceDTO.Counter++; if (InvoiceDTO.LastMonth != invoice.InvoiceDate.Month) { InvoiceDTO.Counter = 0; InvoiceDTO.LastMonth = invoice.InvoiceDate.Month; } invoice.InvoiceCode = invoice.InvoiceDate.Year.ToString() + invoice.InvoiceDate.Month.ToString("00") + "-" + InvoiceDTO.Counter.ToString("0000"); foreach (var item in customerManager.GetCustomers()) { if (item.Name.Equals(invoice.CustomerName)) { customer = item; } } mgr.AddInvoice(invoice); return(RedirectToAction("Index")); } catch { return(View()); } }
public ActionResult Create(FormCollection collection) { try { // TODO: Add insert logic here int nr = Convert.ToInt32(Request.Form["InvoiceNr"]); string companyInfo = Request.Form["CompanyInfo"]; string customerInfo = Request.Form["CustomerInfo"]; DateTime date = DateTime.Now; ICollection <InvoiceDetailDTO> details = null; StatusDTO status = StatusDTO.InProgress; mgr.AddInvoice(nr, companyInfo, customerInfo, date, details, status, null, null); return(RedirectToAction("Index")); } catch { return(View()); } }
public IActionResult CreateInvoice(InvoiceOrder invoiceOrder) { if (!ModelState.IsValid || invoiceOrder.InvoiceProducts.Count() == 0) { return(BadRequest()); } foreach (InvoiceProducts product in invoiceOrder.InvoiceProducts) { product.Invoice = invoiceOrder.Invoice; } invoiceOrder.Invoice.Date = DateTime.UtcNow; UpdateProducts(invoiceOrder.InvoiceProducts); invoiceManager.AddInvoice(invoiceOrder.Invoice, invoiceOrder.InvoiceProducts); invoiceManager.Complete(); return(Ok(invoiceOrder.Invoice)); }