Esempio n. 1
0
        public static DataStatus Create(DataSource ds, string email, int type)
        {
            EmailHash hash = new EmailHash()
            {
                Email = email.ToLower(), Type = type, Hash = Guid.NewGuid(), CreationDate = DateTime.Now
            };

            if (ExecuteCount <EmailHash>(ds, P("Type", hash.Type) & P("Email", hash.Email)) > 0)
            {
                return(hash.Update(ds));
            }
            return(hash.Insert(ds));
        }
Esempio n. 2
0
        public static bool Equals(DataSource ds, string email, int type, Guid hash)
        {
            if (string.IsNullOrEmpty(email) || hash == Guid.Empty)
            {
                return(false);
            }
            EmailHash eh = ExecuteSingleRow <EmailHash>(ds, P("Type", type) & P("Email", email.ToLower()));

            if (eh == null)
            {
                return(false);
            }
            if (hash != eh.Hash)
            {
                return(false);
            }
            //if (eh.CreationDate.AddMinutes(1) < DateTime.Now)
            //    return false;
            eh.Hash         = Guid.Empty;
            eh.CreationDate = (DateTime)Types.GetDefaultValue(TType <DateTime> .Type);
            eh.Update(ds);
            return(true);
        }