public async Task <IActionResult> CreateClaim([DataSourceRequest] DataSourceRequest request, [FromQuery] int authenticationTypeId)
        {
            var model = new AuthenticationClaimMapping();

            if (ModelState.IsValid)
            {
                await this.TryUpdateModelAsync <AuthenticationClaimMappingViewModel, AuthenticationClaimMapping>(model);

                model.AuthenticationTypeId = authenticationTypeId;
                db.AuthenticationClaimMappings.Add(model);
                await db.SaveChangesAsync();
            }

            return(Json(await new[] { model.ToViewModel <AuthenticationClaimMapping, AuthenticationClaimMappingViewModel>() }.ToDataSourceResultAsync(request, ModelState)));
        }
        /// <summary>
        /// Estimats a claimData item from a given mapping and an original claim
        /// </summary>
        /// <param name="map">the mapping instruction for estimating a new claim</param>
        /// <param name="original">the original claim-value</param>
        /// <returns>a new claim that must be added to the currently logged on user</returns>
        private ClaimData TryGetClaim(AuthenticationClaimMapping map, ClaimData original)
        {
            try
            {
                return(new ClaimData
                {
                    Type = original.FormatText(map.OutgoingClaimName),
                    ValueType = !string.IsNullOrEmpty(map.OutgoingValueType) ? original.FormatText(map.OutgoingValueType) : "",
                    Issuer = !string.IsNullOrEmpty(map.OutgoingIssuer) ? original.FormatText(map.OutgoingIssuer) : "",
                    OriginalIssuer = !string.IsNullOrEmpty(map.OutgoingOriginalIssuer) ? original.FormatText(map.OutgoingOriginalIssuer) : "",
                    Value = !string.IsNullOrEmpty(map.OutgoingClaimValue) ? original.FormatText(map.OutgoingClaimValue) : ""
                });
            }
            catch
            {
            }

            return(null);
        }