public ActionResult Create(CreateInvoice formModel) { InvoiceRepo repo = new InvoiceRepo(context); try { var invoice = new Invoice(formModel.InvoiceNumber, formModel.Status, formModel.ClientId); invoice.Status = InvoiceStatus.Open; repo.Insert(invoice); return(RedirectToAction("Index")); } catch (DbUpdateException ex) { HandleDbUpdateException(ex); } formModel.PopulateSelectLists(context); return(View("Create", formModel)); }