public ActionResult Create(ThemeViewModel model, int?sectionId) { model.DatePublication = DateTime.Now; model.CreatorId = Convert.ToInt32(HttpContext.Profile.GetPropertyValue("Id")); model.CountViews = 0; service.CreateTheme(model.ToBllTheme()); var themes = service.GetBySectionId(sectionId.Value).Select(theme => theme.ToModelTheme()); return(PartialView("_ThemeOfSectionTable", themes)); }
public ActionResult CreateTheme(ThemeViewModel model) { if (themeService.GetOneByPredicate(t => t.Name == model.Name) != null) { ModelState.AddModelError("", "Category with this name already registered."); return(View(model)); } if (model == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } var newTheme = model.ToBllTheme(); themeService.Create(newTheme); return(RedirectToAction("CreateTest")); }