mirror of
https://github.com/fergalmoran/podnoms.git
synced 2025-12-22 17:28:43 +00:00
19 lines
697 B
C#
19 lines
697 B
C#
using Microsoft.AspNetCore.Identity;
|
|
using Microsoft.AspNetCore.Mvc.ModelBinding;
|
|
|
|
namespace PodNoms.Api.Utils {
|
|
public static class Errors {
|
|
public static ModelStateDictionary AddErrorsToModelState(IdentityResult identityResult, ModelStateDictionary modelState) {
|
|
foreach (var e in identityResult.Errors) {
|
|
modelState.TryAddModelError(e.Code, e.Description);
|
|
}
|
|
|
|
return modelState;
|
|
}
|
|
|
|
public static ModelStateDictionary AddErrorToModelState(string code, string description, ModelStateDictionary modelState) {
|
|
modelState.TryAddModelError(code, description);
|
|
return modelState;
|
|
}
|
|
}
|
|
} |