Ejemplo n.º 1
0
        public void AddLink(string obj, LoginProfile profile)
        {
            var accountLink = new AccountLinks
            {
                Id       = obj,
                UId      = profile.HashId,
                Provider = profile.Provider,
                Profile  = profile.ToSerializedString(),
                Linked   = DateTime.UtcNow
            };

            AccountLinkContext.AddOrUpdate(r => r.AccountLinks, accountLink);
            AccountLinkContext.SaveChanges();

            AccountLinkerStorage.RemoveFromCache(obj);
        }
Ejemplo n.º 2
0
        public void RemoveProvider(string obj, string provider = null, string hashId = null)
        {
            using var tr = AccountLinkContext.Database.BeginTransaction();

            var accountLinkQuery = AccountLinks
                                   .Where(r => r.Id == obj);

            if (!string.IsNullOrEmpty(provider))
            {
                accountLinkQuery = accountLinkQuery.Where(r => r.Provider == provider);
            }
            if (!string.IsNullOrEmpty(hashId))
            {
                accountLinkQuery = accountLinkQuery.Where(r => r.UId == hashId);
            }

            var accountLink = accountLinkQuery.FirstOrDefault();

            AccountLinks.Remove(accountLink);
            AccountLinkContext.SaveChanges();

            tr.Commit();
            AccountLinkerStorage.RemoveFromCache(obj);
        }