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 async Task <IActionResult> CreateTheme(ThemeCreateModel theme) { try { User user = await _userManager.GetUserAsync(User); _themeService.CreateTheme(theme, user.Id); List <ThemeModel> themes = _themeService.GetAllThemes(); return(PartialView("_AllThemes", themes)); } catch (Exception e) { return(StatusCode(500, e)); } }
public ActionResult CreateTheme(CreateThemeViewModel model) { if (ModelState.IsValid) { Regex regex = new Regex(@"\r\n"); model.ThemeText = regex.Replace(model.ThemeText, ""); model.ThemeText = model.ThemeText.Trim(); model.UserId = User.Identity.GetUserId(); var createThemeDto = Mapper.Map <DTOCreateThemeViewModel>(model); ThemeService.CreateTheme(createThemeDto); return(RedirectToAction("Index")); } return(View(model)); }
public async Task <ActionResult <ThemeViewModel> > CreateTheme(SaveThemeViewModel theme) { return(await _themeService .CreateTheme(theme) .HandleFailuresOrOk()); }