Ejemplo n.º 1
0
 public virtual ActionResult User(UserModel userModel)
 {
     Option<User> user;
     using (var context = new FourWarContext())
     {
         user = Option.Some(context.Users.FirstOrDefault(u => u.FoursquareId == userModel.Id));
     }
     if (user.None)
     {
         return Json("User not found");
     }
     return Json("user found");
 }
Ejemplo n.º 2
0
 private void CheckDatabase()
 {
     try
     {
         using (var context = new FourWarContext())
         {
             var user = context.Users.FirstOrDefault();
         }
     }
     catch (Exception e)
     {
         throw new HttpException((int) HttpStatusCode.NotFound, "Database is unavailable", e);
     }
 }
Ejemplo n.º 3
0
 public virtual ActionResult Authorize(string code)
 {
     if (string.IsNullOrWhiteSpace(code))
     {
         return Json("Failed to authenticate");
     }
     var api = new SharpSquare(ClientId, ClientSecret);
     string token = api.GetAccessToken(RedirectUrl, code);
     api.SetAccessToken(token);
     var user = api.GetUser();
     // todo store token to user
     using(var context = new FourWarContext())
     {
         /*
         var user = context.Users.Create();
         user.OAuthToken = token;
         user
          * */
     }
     return RedirectToAction(MVC.Home.Index());
 }