Exemple #1
0
        public async Task <IActionResult> Edit(ApiResourceSecretEditViewModel viewmodel)
        {
            var isRecordFound = _dbContext.ApiResourceSecrets.Any(o => o.Id == viewmodel.Id);

            if (ModelState.IsValid && isRecordFound)
            {
                var record = _mapper.Map <ApiResourceSecret>(viewmodel);

                if (!string.IsNullOrEmpty(viewmodel.NewSecret) && !string.IsNullOrWhiteSpace(viewmodel.NewSecret))
                {
                    record.Value = new IdentityServer4.Models.Secret(viewmodel.NewSecret.ToSha256()).Value;
                }

                _dbContext.Update(record);
                var result = await _dbContext.SaveChangesAsync();

                if (result > 0)
                {
                    return(RedirectToAction("Details", "ApiResources", new { id = viewmodel.ApiResourceId }));
                }

                ModelState.AddModelError("", "Failed");
            }

            return(View(viewmodel));
        }
        public async Task <IActionResult> Edit(ApiScopeClaimEditViewModel viewmodel)
        {
            var isRecordFound = _dbContext.ApiScopeClaims.Any(o => o.Id == viewmodel.Id);

            if (ModelState.IsValid && isRecordFound)
            {
                var record = _mapper.Map <ApiScopeClaim>(viewmodel);

                _dbContext.Update(record);
                var result = await _dbContext.SaveChangesAsync();

                if (result > 0)
                {
                    return(RedirectToAction("Details", "ApiScopes", new { id = viewmodel.ScopeId }));
                }

                ModelState.AddModelError("", "Failed");
            }

            return(View(viewmodel));
        }
Exemple #3
0
        public async Task <IActionResult> Edit(ClientPostLogoutRedirectUriEditViewModel viewmodel)
        {
            var isRecordFound = _dbContext.ClientPostLogoutRedirectUris.Any(o => o.Id == viewmodel.Id);

            if (ModelState.IsValid && isRecordFound)
            {
                var record = _mapper.Map <ClientPostLogoutRedirectUri>(viewmodel);

                _dbContext.Update(record);
                var result = await _dbContext.SaveChangesAsync();

                if (result > 0)
                {
                    return(RedirectToAction("Details", "Clients", new { id = viewmodel.ClientId }));
                }

                ModelState.AddModelError("", "Failed");
            }

            return(View(viewmodel));
        }
        public async Task <IActionResult> Edit(ClientEditViewModel viewmodel)
        {
            var isRecordFound = await _dbContext.Clients.AnyAsync(u => u.Id == viewmodel.Id);

            if (ModelState.IsValid && isRecordFound)
            {
                var record = _mapper.Map <Client>(viewmodel);

                _dbContext.Update(record);
                var result = await _dbContext.SaveChangesAsync().ConfigureAwait(false);

                if (result > 0)
                {
                    return(RedirectToAction(nameof(Index)));
                }

                ModelState.AddModelError("", "Failed");
            }

            return(View(viewmodel));
        }
Exemple #5
0
        public async Task <IActionResult> Edit(ApiResourceEditViewModel viewmodel)
        {
            var isRecordFound = _dbContext.ApiResources.Any(o => o.Id == viewmodel.Id);

            if (ModelState.IsValid && isRecordFound)
            {
                var record = _mapper.Map <ApiResource>(viewmodel);
                record.Updated = DateTime.UtcNow;

                _dbContext.Update(record);
                var result = await _dbContext.SaveChangesAsync();

                if (result > 0)
                {
                    return(RedirectToAction(nameof(Index)));
                }

                ModelState.AddModelError("", "Failed");
            }

            return(View(viewmodel));
        }