public AccountsBaseViewModel(IUserDialogs userDialogs, IMvxMessenger mvxMessenger, AppHelper appHelper, IOAuthService oauthService, INotificationService notificationService, IAuthenticationService authenticationService) : base(userDialogs, mvxMessenger, appHelper) { _oAuthService = oauthService; _notificationService = notificationService; _authenticationService = authenticationService; // Create Reactive Commands LoginWithFacebookCommand = ReactiveCommand.CreateFromObservable <Unit, string>( (param) => { ResetCommonProps(); return(oauthService .Authenticate(new ParentFacebookOAuth2()) .Do(AuthDict => { if (!AuthDict.ContainsKey("access_token") || string.IsNullOrEmpty(AuthDict["access_token"])) { throw new OAuthInvalidAccessTokenException(); } HandleIsExecuting(true, AppResources.Login_Authenticating_Facebook, FontAwesomeFont.Facebook); }) .SelectMany(AuthDict => authenticationService.LoginWithFacebook(AuthDict["access_token"]))); }); LoginWithFacebookCommand.Subscribe(HandleAuthSuccess); LoginWithFacebookCommand.ThrownExceptions.Subscribe(HandleExceptions); LoginWithGoogleCommand = ReactiveCommand.CreateFromObservable <Unit, string>( (param) => { ResetCommonProps(); return(oauthService .Authenticate(new ParentGoogleOAuth2()) .Do(AuthDict => { if (!AuthDict.ContainsKey("access_token") || string.IsNullOrEmpty(AuthDict["access_token"])) { throw new OAuthInvalidAccessTokenException(); } HandleIsExecuting(true, AppResources.Login_Authenticating_Google, FontAwesomeFont.Google); }) .SelectMany(AuthDict => authenticationService.LoginWithGoogle(AuthDict["access_token"]))); }); LoginWithGoogleCommand.Subscribe(HandleAuthSuccess); LoginWithGoogleCommand.ThrownExceptions.Subscribe(HandleExceptions); }
public Task Facebook([FromBody] LoginWithFacebookCommand command, CancellationToken cancellationToken) { return(_mediator.Send(command, cancellationToken)); }