public ActionResult CreateNewInvoice() { var newModel = new NewStockInvoiceVM { SupplierId = -1, InvoiceDate = DateTime.Today }; var sup = ViewBag.Suppliers as List <Supplier>; sup.Insert(0, new Supplier { SupplierId = -1, Name = "None", PreferedExchangeRate = new ExchangeRate { RateToGBP = 0 } }); ViewBag.Suppliers = sup; return(PartialView(newModel)); }
public ActionResult CreateNewInvoice(NewStockInvoiceVM mNewStockInvoiceVm) { if (ModelState.IsValid) { var sinv = new StockInvoice(); if (TryUpdateModel(sinv)) { var pExRate = _supSvc.GetSupplier(sinv.SupplierId).PreferedExchangeRate; sinv.ExchangeRate = pExRate; sinv.ExchangeRateId = pExRate.ExchangeRateId; sinv.InvoiceCurrency = new ForeignCurrency(pExRate); if (ExecuteRepositoryAction(() => { _stockInvSvc.AddInvoice(sinv); _stockInvSvc.CommitChanges(); })) { return(ReturnJsonFormSuccess(sinv.StockInvoiceid)); } } } return(PartialView(mNewStockInvoiceVm)); }