public ActionResult Edit(Guid id, ThemeEditorViewModel model) { if (ModelState.IsValid == false) { return View(model); } var userId = User.Identity.UserId(); var theme = this.DB.Themes.First(t => t.ThemeId == id && t.Owner == userId); theme.Description = model.Description; this.DB.SaveChanges(); return Redirect("~/"); }
public ActionResult Post(string themeType, ThemeEditorViewModel model) { model.ThemeType = Enum<ThemeType>.Parse(themeType); if (ModelState.IsValid == false) { return View(model); } this.DB.Themes.Add(new Theme { Owner = User.Identity.UserId(), ThemeType = (int)Enum<ThemeType>.Parse(themeType), Description = model.Description }); this.DB.SaveChanges(); return Redirect("~/"); }