Exemplo n.º 1
0
        /// <summary>
        ///     Method saves edited theme
        /// </summary>
        /// <param name="theme">Edited theme</param>
        /// <returns>Theme that was edited</returns>
        public Theme Edit(Theme theme)
        {
            var oldTheme      = GetThemeById(theme.ThemeId);
            var themeWithName = GetThemeByName(theme.Name);

            if (themeWithName == null || themeWithName.ThemeId == theme.ThemeId)
            {
                return(_themeRepository.Edit(theme));
            }
            return(null);
        }
Exemplo n.º 2
0
        public async Task <IActionResult> Edit(int id, Theme theme)
        {
            if (id != theme.Id || theme == null)
            {
                return(NotFound());
            }

            try
            {
                await _repository.Edit(theme);
            }
            catch
            {
                return(StatusCode(500));
            }

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