public ActionResult Create(Investment investment) { try { //Note 123456 seed number should be avoided or stored in config file. If I delete any account then I might end up duplicating the account number. var accountNumber = (123456 + db.Investments.Count()).ToString().PadLeft(10, '0'); investment.InvestmentNo = accountNumber; // TODO: Add insert logic here db.Investments.Add(investment); db.SaveChanges(); return PartialView("_InvestmentThanks"); } catch { return View(); } }
// GET: Investment/Details public ActionResult Details() { var investment = new Investment { InvestmentNo = "0000123456", FirstName = "Ajit", LastName = "Sahu", Address = "101 Sine Street, Homebush, Sydney, NSW 2000", MobileNo = "0422333444", Landline = "91114343", OtherNo = "91114343", Email = "*****@*****.**", InvestmentAmount = 5441.50M, InvestmentDate = "19/11/2012", IsActive = true, Comment = "This is investment" }; return View(investment); }