Пример #1
0
        public bool AddConfirmationKey(WebUser user, string key, ConfirmType type, DateTime?expiration = null)
        {
            if (user == null || string.IsNullOrEmpty(key))
            {
                return(false);
            }
            Confirmationkey confirm = new Confirmationkey
            {
                UserId      = user.UserId,
                KeyString   = key,
                ConfirmType = type,
                Expiration  = expiration
            };

            if (_awdwareCoreDbContext.UserConfirmations.Any(x => (x.UserId == confirm.UserId && x.ConfirmType == confirm.ConfirmType)))
            {
                throw new InvalidOperationException("The confirm key already exists");
            }
            else
            {
                _awdwareCoreDbContext.UserConfirmations.Add(confirm);
            }

            _awdwareCoreDbContext.SaveChanges();
            return(true);
        }
Пример #2
0
        public bool ConfirmationLinkIsValid(string link, ConfirmType type)
        {
            Confirmationkey confirm = _awdwareCoreDbContext.UserConfirmations.First(
                x => (x.KeyString == link && x.ConfirmType == type));

            return(confirm.Expiration > DateTime.Now);
        }