public ActionResult Create(PortfolioCreationDto portfolioParams) { if (ModelState.IsValid) { var currentUser = db.UserProfiles.Single(u => u.UserName == User.Identity.Name); var portfolio = new Portfolio { Name = portfolioParams.Name, Owner = currentUser }; db.Portfolios.Add(portfolio); db.SaveChanges(); return RedirectToAction("Index"); } return View(portfolioParams); }
public ActionResult Edit(Portfolio portfolio) { if (ModelState.IsValid) { db.Entry(portfolio).State = EntityState.Modified; db.SaveChanges(); return RedirectToAction("Index"); } return View(portfolio); }