コード例 #1
0
        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));
        }
コード例 #2
0
        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));
            }
        }
コード例 #3
0
ファイル: HomeController.cs プロジェクト: Yuriy1986/ForumNew
        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));
        }
コード例 #4
0
 public async Task <ActionResult <ThemeViewModel> > CreateTheme(SaveThemeViewModel theme)
 {
     return(await _themeService
            .CreateTheme(theme)
            .HandleFailuresOrOk());
 }