Exemplo n.º 1
0
        public ActionResult Create(AzureSite azuresite)
        {
            if (ModelState.IsValid)
            {
                db.AzureSites.Add(azuresite);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(azuresite));
        }
Exemplo n.º 2
0
        public ActionResult Callback(string code)
        {
            string accessToken = string.Empty;

            if (TryGetAccessToken(code, out accessToken))
            {
                string username = GetAppHarborUsername(accessToken);
                using (var db = new CcTrayDbContext())
                {
                    Key key = db.Keys.FirstOrDefault(k => k.AccessToken == accessToken);
                    if (key == null)
                    {
                        key = new Key {
                            AccessToken = accessToken
                        };
                        key.ReadonlyToken = Guid.NewGuid().ToString();
                        db.Keys.Add(key);
                    }
                    key.Username = username;
                    db.SaveChanges();
                }
                AppendCookieToResponse(accessToken, username);
                return(RedirectToAction("index", "Home"));
            }
            else
            {
                return(RedirectToAction("index", "Home"));
            }
        }