Ejemplo n.º 1
0
 public void Delete(string token)
 {
     using (var context = new IdeaPoolEntities())
     {
         ForgotPassword passwordtoken = context.ForgotPasswords.SingleOrDefault(x => x.Token == token);
         if (passwordtoken != null)
         {
             context.Entry(passwordtoken).State = System.Data.Entity.EntityState.Deleted;
             context.SaveChanges();
         }
     }
 }
Ejemplo n.º 2
0
        public ForgotPasswordTokenObject Get(string token)
        {
            ForgotPasswordTokenObject passwordToken = null;

            using (var context = new IdeaPoolEntities())
            {
                ForgotPassword forgotPassword = context.ForgotPasswords.SingleOrDefault(x => x.Token == token);
                if (forgotPassword != null)
                {
                    passwordToken = new ForgotPasswordTokenObject
                    {
                        Token          = forgotPassword.Token,
                        ExpiryDateTime = forgotPassword.ExpiryDateTime,
                        UserId         = forgotPassword.UserId
                    };
                }
            }
            return(passwordToken);
        }
Ejemplo n.º 3
0
 public void InsertOrUpdate(int userId, string token)
 {
     using (var context = new IdeaPoolEntities())
     {
         ForgotPassword forgotpassword = context.ForgotPasswords.SingleOrDefault(x => x.UserId == userId);
         if (forgotpassword == null)
         {
             context.ForgotPasswords.Add(new ForgotPassword
             {
                 UserId         = userId,
                 Token          = token,
                 ExpiryDateTime = DateTime.UtcNow.AddDays(1)
             });
         }
         else
         {
             forgotpassword.Token                = token;
             forgotpassword.ExpiryDateTime       = DateTime.UtcNow.AddDays(1);
             context.Entry(forgotpassword).State = System.Data.Entity.EntityState.Modified;
         }
         context.SaveChanges();
     }
 }