public ActionResult Edit(Theme newTheme) { if (ModelState.IsValid) { if (repo.EditTheme(newTheme) > 0) return RedirectToAction("Index"); else ModelState.AddModelError("", "Provider error"); } return View(newTheme); }
/// <summary> /// Create new theme /// </summary> /// <param name="newTheme">New theme</param> /// <returns>0 - if creating fail</returns> public int CreateTheme(Theme newTheme) { modelContainer.Themes.Add(newTheme); return modelContainer.DbSaveChanges(); }
/// <summary> /// Edit theme /// </summary> /// <param name="newTheme">New data</param> /// <returns>0 - if editing fail</returns> public int EditTheme(Theme newTheme) { Theme Theme = modelContainer.Themes.FirstOrDefault(b => b.Id == newTheme.Id); if (Theme != null) { Theme.ThemeName = newTheme.ThemeName; return modelContainer.DbSaveChanges(); } return 0; }