public void UpdateHuy(int ID, string Noidung = "", Planner2.Models.User nguoidung = null)
 {
     using (Models.Planner2Entities db = new Planner2Entities())
     {
         var data = db.MainTasks.Where(c => c.Id == ID).FirstOrDefault();
         data.Status = ConstTrangThai.Huy;
         db.SaveChanges();
     }
 }
        public async Task <ActionResult> ExternalLoginCallback(string returnUrl)
        {
            var loginInfo = await AuthenticationManager.GetExternalLoginInfoAsync();

            if (loginInfo == null)
            {
                return(RedirectToAction("Login"));
            }

            using (Planner2Entities db = new Planner2Entities())
            {
                if (string.IsNullOrEmpty(loginInfo.Email))
                {
                    loginInfo.Email = loginInfo.DefaultUserName;
                }
                var data = db.Users.Where(z => z.Email.ToUpper() == loginInfo.Email.ToUpper()).FirstOrDefault();
                if (data == null)
                {
                    Planner2.Models.User item = new Planner2.Models.User();

                    item.UserName  = loginInfo.Email;
                    item.Email     = loginInfo.Email;
                    item.StaffName = loginInfo.DefaultUserName;
                    db.Users.Add(item);
                    db.SaveChanges();
                }
                data = db.Users.Where(z => z.Email.ToUpper() == loginInfo.Email.ToUpper()).FirstOrDefault();
                if (data != null)
                {
                    Session[LoginAuth.NameSession] = data;

                    HttpCookie cookie = new HttpCookie(LoginAuth.NameSession);
                    string     _Key   = EncryptPassword(data.UserName);
                    cookie.Values["_Key"] = _Key;

                    cookie.Expires = DateTime.Now.AddDays(30);
                    Response.Cookies.Add(cookie);

                    if (Session["lastUrl"] != null)
                    {
                        var lastUrl = (string)Session["lastUrl"];
                        Session["lastUrl"] = null;
                        return(Redirect(lastUrl));
                    }
                    else
                    {
                        Session["lastUrl"] = null;
                        return(RedirectToAction("Index", "Profile"));
                    }
                }
            }
            return(RedirectToAction("INDEX", "PROFILE"));
        }