public ActionResult <Theme> PostTheme(ThemeDTO theme)
        {
            Theme newTheme = new Theme()
            {
                Title = theme.Title
            };

            _themeRepository.Add(newTheme);
            _themeRepository.SaveChanges();

            return(CreatedAtAction(nameof(GetAllThemes), new { id = newTheme.Id }, newTheme));
        }
Example #2
0
        public async Task <IActionResult> Create(Theme theme)
        {
            try
            {
                await _repository.Add(theme);
            }
            catch
            {
                return(StatusCode(500));
            }

            return(RedirectToAction(nameof(Index)));
        }