using APP.Models; using BWPMModels; using Microsoft.AspNetCore.Identity; using System; using System.Collections.Generic; using System.Linq; using System.Threading; using System.Threading.Tasks; using Newtonsoft.Json; using System.Reflection; using System.Net.Http; using App.Helper; using APP.Helper; namespace APP.Identity { public class UserStoreAppService : IUserEmailStore, IUserPasswordStore, IUserLoginStore, IDisposable { //private IAccountDAL _accountDAL; //public UserStoreAppService(IAccountDAL accountDAL) //{ // _accountDAL = accountDAL; //} public Task AddLoginAsync(AppUser user, UserLoginInfo login, CancellationToken cancellationToken) { throw new NotImplementedException(); } public Task CreateAsync(AppUser user, CancellationToken cancellationToken) { throw new NotImplementedException(); } public Task DeleteAsync(AppUser user, CancellationToken cancellationToken) { throw new NotImplementedException(); } public void Dispose() { } public async Task FindByEmailPasswordAsync(string normalizedEmail, string normalizedPassword, CancellationToken cancellationToken) { App.Helper.HttpClientHelper httpcli = new App.Helper.HttpClientHelper(); User u = new User(); u.email = normalizedEmail; httpcli.CallService("user", normalizedEmail + "/" + normalizedPassword, "GET", u); if (httpcli.Results.resultstatus != true) { return null; } var appUser = new AppUser() { Id = u.ID, PassWord = u.passwort, Email = u.email, FullName = u.username, Avatar = "", Usertype = u.usertype.ToString() }; return appUser; } public async Task FindByEmailAsync(string normalizedEmail, CancellationToken cancellationToken) { App.Helper.HttpClientHelper httpcli = new App.Helper.HttpClientHelper(); User u = new User(); u.email = normalizedEmail; httpcli.CallService("user", "EMail/"+u.email, "GET", u); if (httpcli.Results.resultstatus != true) { return null; } List user = JsonConvert.DeserializeObject>(httpcli.Results.daten); var appUser = new AppUser() { Id = user[0].ID, PassWord = user[0].passwort, Email = user[0].email, FullName = user[0].username, Avatar = "", Usertype = user[0].usertype.ToString() }; return appUser; } public async Task FindByIdAsync(string userId, CancellationToken cancellationToken) { App.Helper.HttpClientHelper httpcli = new App.Helper.HttpClientHelper(); User u = new User(); u.ID = Convert.ToInt32(userId); httpcli.CallService("user", userId, "GET", u); if (httpcli.Results.resultstatus != true) { return null; } List user = JsonConvert.DeserializeObject>(httpcli.Results.daten); var appUser = new AppUser() { Id = user[0].ID, PassWord = user[0].passwort, Email = user[0].email, FullName = user[0].username, Avatar = "", Usertype = user[0].usertype.ToString() }; return appUser; throw new NotImplementedException(); //if (!string.IsNullOrEmpty(userId)) // userId = userId.ToLower(); //cancellationToken.ThrowIfCancellationRequested(); //if (userId == null) throw new ArgumentNullException(nameof(userId)); //var employee = await _accountDAL.GetById(Convert.ToInt32(userId)); //if (employee != null) //{ // var appUser = new AppUser() // { // Id = employee.Id, // PassWord = employee.PassWord, // Email = employee.Email, // FullName = employee.FullName, // Avatar = employee.Avatar // }; // return appUser; //} //return null; } public Task FindByLoginAsync(string loginProvider, string providerKey, CancellationToken cancellationToken) { throw new NotImplementedException(); } public async Task FindByNameAsync(string normalizedUserName, CancellationToken cancellationToken) { App.Helper.HttpClientHelper httpcli = new App.Helper.HttpClientHelper(); AppUser u = new AppUser(); u.Name = normalizedUserName.ToLower(); httpcli.CallService("user", "Email/"+u.Name, "GET", u); if (httpcli.Results.resultstatus != true) { return null; } List user = JsonConvert.DeserializeObject>(httpcli.Results.daten); var appUser = new AppUser() { Id = user[0].ID, PassWord = user[0].passwort, Email = user[0].email, FullName = user[0].username, Avatar = "", Usertype = user[0].usertype.ToString() }; return appUser; } public Task GetEmailAsync(AppUser user, CancellationToken cancellationToken) { throw new NotImplementedException(); } public Task GetEmailConfirmedAsync(AppUser user, CancellationToken cancellationToken) { throw new NotImplementedException(); } public Task> GetLoginsAsync(AppUser user, CancellationToken cancellationToken) { throw new NotImplementedException(); } public Task GetNormalizedEmailAsync(AppUser user, CancellationToken cancellationToken) { throw new NotImplementedException(); } public Task GetNormalizedUserNameAsync(AppUser user, CancellationToken cancellationToken) { throw new NotImplementedException(); } public Task GetPasswordHashAsync(AppUser user, CancellationToken cancellationToken) { cancellationToken.ThrowIfCancellationRequested(); return Task.FromResult(user.PassWord); } public Task GetUserIdAsync(AppUser user, CancellationToken cancellationToken) { cancellationToken.ThrowIfCancellationRequested(); if (user == null) throw new ArgumentNullException(nameof(user)); return Task.FromResult(user.Id.ToString()); } public Task GetUserNameAsync(AppUser user, CancellationToken cancellationToken) { cancellationToken.ThrowIfCancellationRequested(); return Task.FromResult(user.Email); } public Task HasPasswordAsync(AppUser user, CancellationToken cancellationToken) { throw new NotImplementedException(); } public Task RemoveLoginAsync(AppUser user, string loginProvider, string providerKey, CancellationToken cancellationToken) { throw new NotImplementedException(); } public Task SetEmailAsync(AppUser user, string email, CancellationToken cancellationToken) { throw new NotImplementedException(); } public Task SetEmailConfirmedAsync(AppUser user, bool confirmed, CancellationToken cancellationToken) { throw new NotImplementedException(); } public Task SetNormalizedEmailAsync(AppUser user, string normalizedEmail, CancellationToken cancellationToken) { throw new NotImplementedException(); } public Task SetNormalizedUserNameAsync(AppUser user, string normalizedName, CancellationToken cancellationToken) { throw new NotImplementedException(); } public Task SetPasswordHashAsync(AppUser user, string passwordHash, CancellationToken cancellationToken) { throw new NotImplementedException(); } public Task SetUserNameAsync(AppUser user, string userName, CancellationToken cancellationToken) { throw new NotImplementedException(); } public Task UpdateAsync(AppUser user, CancellationToken cancellationToken) { throw new NotImplementedException(); } } }