public async Task <int> UpdateAccountProvider(int accountid, UpdateAccountProviderViewModel model, string username) { var filter = new AccountProviderSpecification(model.Provider, model.ProviderId); var accountprovider = await _accountProviderRepository.GetSingleBySpecAsync(filter); if (accountprovider != null) { if (accountprovider.AccountId != accountid) { return(-1); } return(1); } accountprovider = new AccountProvider() { AccountId = accountid, Email = model.Email, Name = model.Name, Provider = model.Provider, ProviderId = model.ProviderId, AccessToken = model.AccessToken, Expired = DateTime.Now.AddHours(1) }; await _accountProviderRepository.AddAsync(accountprovider); return(2); }
public async Task <AccountProviderViewModel> GetAccountProviderByAccount(int accountid, AccountProviderNames provider) { var filter = new AccountProviderSpecification(accountid, provider); var accountProvider = await _accountProviderRepository.GetSingleBySpecAsync(filter); return(accountProvider != null ? new AccountProviderViewModel(accountProvider) : null); }
public async Task <AuthViewModel> GetAuth(LoginProviderViewModel model) { var filter = new AccountProviderSpecification(model.Provider, model.ProviderId); var accountprovider = await _accountProviderRepository.GetSingleBySpecAsync(filter); if (accountprovider == null) { var account = await _accountRepository.GetAccount(model.Email); if (account == null) { account = new Account() { DateCreated = DateTime.Now, DateModified = DateTime.Now, Email = model.Email, Name = model.Name, Password = "", Actived = true, UserCreated = model.Email, UserModified = model.Email, Address = string.Empty, Phone = string.Empty, Avatar = model.Image, Salt = SecurityHelper.GenerateSalt(), CityId = null, Deleted = false, DistrictId = null, Type = AccountType.HotMom }; await _accountRepository.AddAsync(account); await _walletRepository.CreateWallet(EntityType.Account, account.Id); } accountprovider = new AccountProvider() { AccountId = account.Id, Email = model.Email, Name = model.Name, Provider = model.Provider, ProviderId = model.ProviderId, AccessToken = model.AccessToken, Expired = DateTime.Now.AddHours(1), Link = string.Empty }; await _accountProviderRepository.AddAsync(accountprovider); return(GetAuth(account)); } else { accountprovider.AccessToken = model.AccessToken; await _accountProviderRepository.UpdateAsync(accountprovider); return(await GetAuth(accountprovider.AccountId)); } }
public async Task UpdateFacebookUrlProfile(int accountid, AccountProviderNames provider, string urlFacebookProfile) { var filter = new AccountProviderSpecification(accountid, provider); var accountProvider = await _accountProviderRepository.GetSingleBySpecAsync(filter); accountProvider.Link = urlFacebookProfile; await _accountProviderRepository.UpdateAsync(accountProvider); }
public async Task <AccountProviderViewModel> GetAccountProviderByProvider(AccountProviderNames provider, string providerid, string newtoken) { var filter = new AccountProviderSpecification(provider, providerid); var accountProvider = await _accountProviderRepository.GetSingleBySpecAsync(filter); if (accountProvider != null) { return(new AccountProviderViewModel(accountProvider)); } return(null); }