当前位置: 首页>>代码示例>>C#>>正文


C# Identity.IdentityResult类代码示例

本文整理汇总了C#中Microsoft.AspNet.Identity.IdentityResult的典型用法代码示例。如果您正苦于以下问题:C# IdentityResult类的具体用法?C# IdentityResult怎么用?C# IdentityResult使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


IdentityResult类属于Microsoft.AspNet.Identity命名空间,在下文中一共展示了IdentityResult类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetErrorResult

        private IHttpActionResult GetErrorResult(IdentityResult result)
        {
            if (result == null)
            {
                return InternalServerError();
            }

            if (!result.Succeeded)
            {
                if (result.Errors != null)
                {
                    foreach (var error in result.Errors)
                    {
                        ModelState.AddModelError("",error);
                    }
                }

                if (ModelState.IsValid)
                {
                    //No Modelstate errors are available to send so just return bad request
                    return BadRequest();
                }
                return BadRequest(ModelState);
            }

            return null;
            
            throw new NotImplementedException();
        }
开发者ID:cjcoughlan,项目名称:angular-exercise,代码行数:29,代码来源:AccountController.cs

示例2: AddErrors

 private void AddErrors(IdentityResult result)
 {
     foreach (var error in result.Errors)
     {
         ModelState.AddModelError("", error);
     }
 }
开发者ID:Atzie,项目名称:CopernicaNET,代码行数:7,代码来源:ManagePassword.aspx.cs

示例3: GetErrorResult

        private IHttpActionResult GetErrorResult(IdentityResult result)
        {
            if (result == null)
            {
                return InternalServerError();
            }

            if (!result.Succeeded)
            {
                if (result.Errors != null)
                {
                    foreach (String error in result.Errors)
                    {
                        ModelState.AddModelError("", error);
                    }
                }

                if (ModelState.IsValid)
                {
                    //Ingen fejlkode, derfor sendes der bare en badrequest
                    return BadRequest();
                }
            }

            return null;

        }
开发者ID:Ephis,项目名称:VisitMe,代码行数:27,代码来源:AccountController.cs

示例4: GetErrorResult

        protected IHttpActionResult GetErrorResult(IdentityResult result)
        {
            if (result == null)
            {
                return this.InternalServerError();
            }

            if (!result.Succeeded)
            {
                if (result.Errors != null)
                {
                    foreach (var error in result.Errors)
                    {
                        this.ModelState.AddModelError(string.Empty, error);
                    }
                }

                if (this.ModelState.IsValid)
                {
                    return this.BadRequest();
                }

                return this.BadRequest(this.ModelState);
            }

            return null;
        }
开发者ID:Team-Blush,项目名称:Pigeon,代码行数:27,代码来源:BaseApiController.cs

示例5: GetErrorResult

        //rolling up error message to return error result
        private IHttpActionResult GetErrorResult(IdentityResult result)
        {
            if (result == null)
            {
                return InternalServerError();
            }

            if(!result.Succeeded)
            {
                if (result.Errors != null)
                {
                    foreach (string error in result.Errors)
                    {
                        ModelState.AddModelError("", error);
                    }

                }
                if (ModelState.IsValid)
                {
                    //no model state errors available to send, just send bad request
                    return BadRequest();
                }
                return BadRequest(ModelState);
            }
            return null;
        }
开发者ID:RickNog,项目名称:16-PropertyManager,代码行数:27,代码来源:AccountsController.cs

示例6: ValidarErroresResultado

 /// <summary>
 /// Método que realiza la validación de errores que se puedan presentar durante el proceso
 /// </summary>
 /// <param name="result"></param>
 /// <returns></returns>
 private IHttpActionResult ValidarErroresResultado(IdentityResult result)
 {
     if (result == null)
     {
         return InternalServerError();
     }
     if (!result.Succeeded)
     {
         if (result.Errors != null)
         {
             foreach (string error in result.Errors)
             {
                 ModelState.AddModelError("", error);
             }
         }
         if (ModelState.IsValid)
         {
             // Se retorna simplemente un bad request en caso de que no se encuentre un state valido
             return BadRequest();
         }
         //Se retorna la información con el error
         return BadRequest(ModelState);
     }
     return null;
 }
开发者ID:correobasura,项目名称:repositorioAngujarNet,代码行数:30,代码来源:AccountController.cs

示例7: GetErrorResult

        private IHttpActionResult GetErrorResult(IdentityResult result)
        {
            if (result == null)
            {
                return InternalServerError();
            }

            if (!result.Succeeded)
            {
                if (result.Errors != null)
                {
                    foreach (string error in result.Errors)
                    {
                        ModelState.AddModelError("error", error);
                    }
                }

                if (ModelState.IsValid)
                {
                    // Ошибки ModelState для отправки отсутствуют, поэтому просто возвращается пустой BadRequest.
                    return BadRequest();
                }

                return BadRequest(ModelState);
            }

            return null;
        }
开发者ID:o-panikarovskiy,项目名称:fms,代码行数:28,代码来源:AuthController.cs

示例8: AddErrors

 private static void AddErrors(IdentityResult result, ModelMethodContext context)
 {
     foreach (var error in result.Errors)
      {
     context.ModelState.AddModelError("", error);
      }
 }
开发者ID:unclebuddhabelly,项目名称:NavigationIdentity2,代码行数:7,代码来源:AccountController.Helpers.cs

示例9: GetErrorResult

        protected IHttpActionResult GetErrorResult(IdentityResult result)
        {
            if (result == null)
            {
                return InternalServerError();
            }

            if (!result.Succeeded)
            {
                if (result.Errors != null)
                {
                    foreach (string error in result.Errors)
                    {
                        ModelState.AddModelError("", error);
                    }
                }

                if (ModelState.IsValid)
                {
                    // No ModelState errors are available to send, so just return an empty BadRequest.
                    return BadRequest();
                }

                return BadRequest(ModelState);
            }

            return null;
        }
开发者ID:moytho,项目名称:AspNetIdentity,代码行数:28,代码来源:BaseApiController.cs

示例10: AddErrors

 private void AddErrors(IdentityResult result)
 {
     foreach (string str in result.Errors)
     {
         base.ModelState.AddModelError("", str);
     }
 }
开发者ID:clabanow,项目名称:FutureCodr,代码行数:7,代码来源:AccountController.cs

示例11: AddErrorsFromResult

 private void AddErrorsFromResult(IdentityResult result)
 {
     foreach (string error in result.Errors)
     {
         ModelState.AddModelError("", error);
     }
 }
开发者ID:erickm93,项目名称:IdentityModel,代码行数:7,代码来源:RoleAdminController.cs

示例12: IsFailure

		public static void IsFailure(IdentityResult result, IdentityError error)
		{
			Assert.NotNull(result);
			Assert.False(result.Succeeded);
			Assert.Equal(error.Description, result.Errors.First().Description);
			Assert.Equal(error.Code, result.Errors.First().Code);
		}
开发者ID:saan800,项目名称:SaanSoft.AspNet.Identity3.MongoDB,代码行数:7,代码来源:IdentityResultAssert.cs

示例13: AddErrors

 protected void AddErrors(IdentityResult result)
 {
     foreach (var error in result.Errors)
     {
         this.ModelState.AddModelError(string.Empty, error);
     }
 }
开发者ID:vbishurov,项目名称:SoftUni-ASP.NETMVC,代码行数:7,代码来源:BaseIdentityController.cs

示例14: GetErrorResult

        private IHttpActionResult GetErrorResult(IdentityResult result)
        {
            if (result == null)
            {
                return InternalServerError();
            }

            if (!result.Succeeded)
            {
                if (result.Errors != null)
                {
                    foreach (string error in result.Errors)
                    {
                        ModelState.AddModelError("", error);
                    }
                }

                if (ModelState.IsValid)
                {
                    // No ModelState errors to send, so send a Bad Request
                    return BadRequest();
                }

                // Return the errors
                return BadRequest(ModelState);
            }
            
            return null;
        }
开发者ID:okusnadi,项目名称:personal-finance,代码行数:29,代码来源:UserAccountController.cs

示例15: RegisterCustomerAsync

        public async Task<IdentityResult> RegisterCustomerAsync(UserModel userModel, AppRole appRole = AppRole.customer)
        {
            var addToRoleResult = new IdentityResult();
            // Add generate username to the model
            IdentityUser user = new IdentityUser
            {
                UserName = userModel.UserName,
                Email = userModel.EmailAddress,
                EmailConfirmed = true,
                PhoneNumber = userModel.PhoneNumber,
                PhoneNumberConfirmed = true,
            };

            var result = await _userManager.CreateAsync(user, userModel.Password);

            //Role-user combination is managed as Contact-Role combination in ContactRole table
            //Create Role Admin if it does not exist
            var _role = await _roleManager.FindByNameAsync(appRole.ToString());
            if (_role == null)
            {
                _role = new IdentityRole(appRole.ToString());
                var roleresult = await _roleManager.CreateAsync(_role);
            }
            var rolesForUser = await _userManager.GetRolesAsync(user.Id);
            if (!rolesForUser.Contains(_role.Name))
            {
                addToRoleResult = await _userManager.AddToRoleAsync(user.Id, _role.Name);
            }

            return addToRoleResult;
        }
开发者ID:itssourabh22,项目名称:projectIGI,代码行数:31,代码来源:AuthRepository.cs


注:本文中的Microsoft.AspNet.Identity.IdentityResult类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。