當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。