public async Task <ServiceResponseObject <AuthResponse> > Register(RegisterViewModel model) { if (ModelState.IsValid) { AuthMethods AuthData = new AuthMethods(_userManager, _signInManager, _roleManager, _boxContext); var Result = await AuthData.Register(model); return(Result); } ServiceResponseObject <AuthResponse> response = new ServiceResponseObject <AuthResponse>(); response.Status = ResponseResult.Error; List <string> errors = ModelState.Values.Aggregate( new List <string>(), (a, c) => { a.AddRange(c.Errors.Select(r => r.ErrorMessage)); return(a); }, a => a ); response.Message = errors[0]; return(response); }