public MainPageViewModel() { _fbservice = new FbService(); _modelhelper = new ModelHelper(); DeviceIsConnected(); }
public AddPageViewModel() { _dialoghelper = new DialogHelper(); _stringshelper = new StringsHelper(); _fbservice = new FbService(); _modelhelper = new ModelHelper(); Page = "facebook.com/"; }
public FacebookAuthController( UserManager <ApplicationUser> userManager, ApplicationDbContext dbContext, FbService fbService, ITokenService tokenService) { _fbService = fbService ?? throw new NullReferenceException(); _userManager = userManager ?? throw new NullReferenceException(); _dbContext = dbContext ?? throw new NullReferenceException(); _tokenService = tokenService ?? throw new NullReferenceException(); }
public async Task <bool> AddUserSocialAsync(int userId, string code, SocialType socialType) { Logger.LogInformation($"{nameof(AccountService)}.{nameof(AddUserSocialAsync)}.Start"); NormalizedSocialUserData user; switch (socialType) { case SocialType.Facebook: user = await FbService.GetUserInfoAsync(code); break; case SocialType.Vk: user = await VkService.GetUserInfoAsync(code); break; case SocialType.Twiter: case SocialType.GooglePlus: case SocialType.Telegram: case SocialType.Badoo: case SocialType.Nothing: default: throw new Exception("We do not support this social network."); } var social = new SocialEntity { InternalId = userId, ExternalId = user.ExternalId, SocialType = socialType, Email = user.ExternalEmail, ExternalToken = user.ExternalToken, ExpiresIn = user.ExpiresIn }; if (!await Db.Users.AddUserSocialAsync(social)) { return(false); } var userInfo = await Db.UsersInfo.FindUserInfoAsync(userId, userId); if (userInfo.OriginalAvatarUrl.IsNullOrEmpty() || MediaConverter.IsStandardBackground(userInfo.OriginalAvatarUrl) && !user.OriginalPhotoUrl.IsNullOrEmpty()) { userInfo.OriginalAvatarUrl = await UploadAvatarUrlOrGetStandard(user.OriginalPhotoUrl); } var updateUser = new UpdateUserInfoDto { UserId = userInfo.UserId, FristName = userInfo.FirstName, LastName = userInfo.LastName, BirthDate = userInfo.BirthDate, SexType = userInfo.SexType, City = userInfo.City, Description = userInfo.Description }; try { await UpdateUserInfoAsync(updateUser); } catch (Exception e) { Logger.LogError(e, $"{nameof(AccountService)}.{nameof(AddUserSocialAsync)} Error"); } Logger.LogInformation($"{nameof(AccountService)}.{nameof(AddUserSocialAsync)}.End"); return(true); }