public ActionResult Create(Fund fund) { if(ModelState.IsValid) { SystemEntities repository = new SystemEntities(); repository.Funds.Add(fund); repository.SaveChanges(); return RedirectToAction("Index", "Home"); } PopulateViewBag(); return View(fund); }
public ActionResult Edit(int id, FormCollection collection) { SystemEntities repository = new SystemEntities(); Fund fund = repository.Funds.Find(id); if(TryUpdateModel(fund)) { repository.SaveChanges(); return RedirectToAction("index", "Home"); } else { PopulateViewBag(); return View(fund); } }