fixes the calendar choice

This commit is contained in:
2017-07-05 11:29:15 +02:00
parent 0952e80d4a
commit 13297a04ed
12 changed files with 218 additions and 227 deletions

View File

@ -33,10 +33,9 @@ namespace Yavsc.Helpers
using Yavsc.Models.Calendar;
using Google.Apis.Auth.OAuth2;
using Microsoft.Data.Entity;
using Google.Apis.Auth.OAuth2.Flows;
using Microsoft.AspNet.Identity.EntityFramework;
using Yavsc.Services;
/// <summary>
/// Google helpers.
/// </summary>
@ -86,25 +85,16 @@ namespace Yavsc.Helpers
}
public static async Task<IdentityUserLogin<string>> GetGoogleUserLoginAsync(
this UserManager<ApplicationUser> userManager,
ApplicationDbContext context,
this ApplicationDbContext context,
string yavscUserId)
{
var user = await userManager.FindByIdAsync(yavscUserId);
var user = context.Users.FirstOrDefaultAsync(u=>u.Id==yavscUserId);
if (user==null) return null;
var googleLogin = await context.UserLogins.FirstOrDefaultAsync(
x => x.UserId == yavscUserId && x.LoginProvider == "Google"
);
return googleLogin;
}
public static UserCredential GetGoogleCredential(string googleUserLoginKey)
{
if (string.IsNullOrEmpty(googleUserLoginKey))
throw new InvalidOperationException("No Google login");
var flow = new GoogleAuthorizationCodeFlow(new GoogleAuthorizationCodeFlow.Initializer());
throw new NotImplementedException();
// TokenResponse resp = flow. ;
// return new UserCredential(flow, googleUserLoginKey, resp);
}
public static async Task<Period[]> GetFreeTime (this ICalendarManager manager, string calId, DateTime startDate, DateTime endDate)
{