本文整理汇总了C#中Microsoft.AspNet.Identity.IdentityResult类的典型用法代码示例。如果您正苦于以下问题:C# IdentityResult类的具体用法?C# IdentityResult怎么用?C# IdentityResult使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IdentityResult类属于Microsoft.AspNet.Identity命名空间,在下文中一共展示了IdentityResult类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: AddErrors
public static void AddErrors(this Controller controller, IdentityResult result)
{
foreach (var error in result.Errors)
{
controller.ModelState.AddModelError("", error);
}
}
开发者ID:rabbal,项目名称:Mvc5,代码行数:7,代码来源:ControllerExtentions.cs
示例17: AddErrors
private void AddErrors(IdentityResult result)
{
foreach (var error in result.Errors)
{
ModelState.AddModelError(string.Empty, error.Description);
}
}
开发者ID:RR-Studio,项目名称:RealEstateCrm,代码行数:7,代码来源:EmployeeController.cs
示例18: LazyMock
public static Lazy<IApplicationUserManager> LazyMock(IdentityResult createAsyncResult = null,
IdentityResult addToRoleAsyncResult = null)
{
var result = new Lazy<IApplicationUserManager>(() => Mock(createAsyncResult,
addToRoleAsyncResult));
return result;
}
开发者ID:dyatlov-a,项目名称:cEditor,代码行数:8,代码来源:MockApplicationUserManager.cs
示例19: GetErrorResult
private IHttpActionResult GetErrorResult(IdentityResult result)
{
if (result == null) return InternalServerError();
if (result.Succeeded) return null;
if (result.Errors != null) foreach (string error in result.Errors) ModelState.AddModelError("", error);
if (ModelState.IsValid) return BadRequest();
return BadRequest(ModelState);
}
开发者ID:evasoek,项目名称:Boodschappenlijst-master,代码行数:8,代码来源:UserController.cs
示例20: NullErrorsBecomeDefaultTest
public void NullErrorsBecomeDefaultTest()
{
var result = new IdentityResult(null);
Assert.NotNull(result.Errors);
Assert.False(result.Succeeded);
Assert.Equal(1, result.Errors.Count());
Assert.Equal("An unknown failure has occured.", result.Errors.First());
}
开发者ID:tomi85,项目名称:aspnetidentity,代码行数:8,代码来源:IdentityResultTest.cs
注:本文中的Microsoft.AspNet.Identity.IdentityResult类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论