public async Task <Result <ThemeDto> > UpdateThemeAsync(long themeId, UpdateThemeDto themeDto)
        {
            try
            {
                if (themeDto == null)
                {
                    return(Result <ThemeDto> .GetError(ErrorCode.NotFound, "UpdateThemeDto is null"));
                }
                var foundTheme = await _unitOfWork.ThemeRepository.GetThemeByIdAsync(themeId);

                if (foundTheme == null)
                {
                    return(Result <ThemeDto> .GetError(ErrorCode.NotFound,
                                                       $"Theme with id={themeId} does not exist"));
                }
                foundTheme.Name = themeDto.Name;

                await _unitOfWork.CommitAsync();

                return(Result <ThemeDto> .GetSuccess(_mapper.Map <ThemeDto>(foundTheme)));
            }
            catch
            {
                _unitOfWork.Rollback();

                return(Result <ThemeDto> .GetError(ErrorCode.InternalServerError, "Internal error"));
            }
        }
 public IActionResult UpdateUserTheme(long userId, UpdateThemeDto themeData)
 {
     return(DoWorkAfterValidation(
                () => _accountService.UpdateUserTheme(GetCurrentUserId(), userId, themeData.Theme, userId).Result
                .Match <IActionResult>(
                    Ok,
                    BadRequest
                    )
                ));
 }
Esempio n. 3
0
        public async Task <ActionResult> UpdateTheme(Guid scopeId, Guid themeId, UpdateThemeDto dto)
        {
            if (scopeId != dto.ScopeId || themeId != dto.ThemeId)
            {
                return(BadRequest("Not consistent request"));
            }

            try
            {
                await _scopeService.UpdateTheme(dto.ThemeId, dto.ThemeNewName, dto.NewActual);

                return(NoContent());
            }
            catch (ArgumentException exc)
            {
                return(BadRequest(exc.Message));
            }
        }
        public async Task <IActionResult> UpdateTheme(long id, UpdateThemeDto data)
        {
            await _themeService.UpdateTheme(id, data, _protector.Unprotect(Request.Cookies["accessToken"]));

            return(RedirectToAction("AllThemes", "Themes"));
        }
Esempio n. 5
0
 public async Task UpdateTheme(long id, UpdateThemeDto UpdateDto, string accessToken)
 {
     await
     _apiUtil.PutAsync <UpdateThemeDto>($"{_config.Value.Urls.Api.Https}/api/themes/{id}", UpdateDto, accessToken);
 }
Esempio n. 6
0
        public async Task <ActionResult <IList <ThemeDto> > > UpdateTheme(long themeId, [FromBody] UpdateThemeDto UpdateThemeModel)
        {
            var themeResult = await _themeService.UpdateThemeAsync(themeId, UpdateThemeModel);

            return(themeResult.ToActionResult());
        }