Exemple #1
0
        public ActionResult Edit(Guid id)
        {
            var claimDomainModel = _claimsService.GetById(id);
            var model            = new ClaimViewModel(claimDomainModel);

            return(View(model));
        }
        public async Task <BaseResponse> AssignRoleToClaims([FromBody] AssignRoleToClaimsRequest assignRoleToClaimsRequest)
        {
            BaseResponse baseResponse = new BaseResponse();

            try
            {
                if (ModelState.IsValid)
                {
                    var role = _roleManager.Roles.Where(a => a.Id == assignRoleToClaimsRequest.RoleId).FirstOrDefault();

                    if (role != null)
                    {
                        var OldClaims = await _roleManager.GetClaimsAsync(role);

                        foreach (var item in OldClaims)
                        {
                            await _roleManager.RemoveClaimAsync(role, item);
                        }

                        foreach (var item in assignRoleToClaimsRequest.ClaimId)
                        {
                            var claimResult = _claimsService.GetById(item).Result.Claims.FirstOrDefault();
                            await _roleManager.AddClaimAsync(role, new Claim(claimResult.ActionName, claimResult.Id.ToString()));
                        }
                        return(baseResponse.ToSuccess <BaseResponse>());
                    }
                }
                return(baseResponse.ToIncompleteInput <BaseResponse>());
            }
            catch (Exception ex)
            {
                _logService.LogText(ex.Message);
                return(baseResponse.ToApiError <BaseResponse>());
            }
        }
        public ActionResult Edit(Guid id)
        {
            var claim = _claimServices.GetById(id);
            //if(claim == null) return new HttpNotFoundResult("Claim Not Found");
            var model = new EditClaimViewModel(claim);

            return(View(model));
        }
Exemple #4
0
 public ClaimDto GetClaimById(Guid id, [Service] IClaimsService context)
 {
     return(context.GetById(id).Adapt <ClaimDto>());
 }