Exemple #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));
        }
Exemple #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));
            }
        }
Exemple #3
0
        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));
        }
Exemple #4
0
 public async Task <ActionResult <ThemeViewModel> > CreateTheme(SaveThemeViewModel theme)
 {
     return(await _themeService
            .CreateTheme(theme)
            .HandleFailuresOrOk());
 }