Exemple #1
0
 public ActionResult AddTheme(AddThemeModel theme)
 {
     if (ModelState.IsValid)
     {
         var themeToAdd = new Theme
         {
             SectionId = theme.SectionId,
             UserId = theme.UserId,
             ThemeTitle = theme.ThemeTitle,
             ThemeText = theme.ThemeText,
             CreationDate = DateTime.Now
         };
         repository.AddTheme(themeToAdd);
         TempData["success"] = "Новая тема успешно создана.";
     }
     else
     {
         return View(theme);
     }
     return RedirectToAction("Section", "Forum", new { id = theme.SectionId });
 }
 public void AddTheme(Theme theme)
 {
     try
     {
         context.Themes.Add(theme);
         context.SaveChanges();
     }
     catch { }
 }