private void Login()
 {
     using (var ctx = new RentooloEntities())
     {
         UsersOpenAuthAccounts userOpenAuthAccounts = ctx.UsersOpenAuthAccounts.Where(c => c.ProviderName == ProviderName &&
                                                                                      c.ProviderUserId == ProviderUserId).FirstOrDefault();
         if (userOpenAuthAccounts != null)
         {
             FormsAuthentication.SetAuthCookie(userOpenAuthAccounts.MembershipUserName, createPersistentCookie: false);
             RedirectToReturnUrl();
         }
         else
         {
             return;
         }
     }
 }
        private void AddAccountToExistingUser(string AplicationName, string MembershipUserName)
        {
            using (var ctx = new RentooloEntities())
            {
                UsersOpenAuthAccounts userOpenAuthAccounts = new UsersOpenAuthAccounts();

                userOpenAuthAccounts.ApplicationName    = AplicationName;
                userOpenAuthAccounts.ProviderName       = ProviderName;
                userOpenAuthAccounts.ProviderUserId     = ProviderUserId;
                userOpenAuthAccounts.ProviderUserName   = ProviderUserName;
                userOpenAuthAccounts.MembershipUserName = MembershipUserName;

                UsersOpenAuthData usersOpenAuthData = new UsersOpenAuthData();

                usersOpenAuthData.ApplicationName    = AplicationName;
                usersOpenAuthData.MembershipUserName = MembershipUserName;
                usersOpenAuthData.HasLocalPassword   = true;


                userOpenAuthAccounts.UsersOpenAuthData = usersOpenAuthData;
                usersOpenAuthData.UsersOpenAuthAccounts.Add(userOpenAuthAccounts);

                ctx.UsersOpenAuthAccounts.Add(userOpenAuthAccounts);
                ctx.UsersOpenAuthData.Add(usersOpenAuthData);
                try
                {
                    ctx.SaveChanges();
                }
                catch
                {
                    ModelState.AddModelError("Provider", String.Format("Аккаунт уже создан и привязан к другой учётной записи."));
                    Trace.Warn("OpenAuth", String.Format("Аккаунт уже создан и привязан к другой учётной записи)"));

                    return;
                }
            }
        }