Esempio n. 1
0
 public bool InvalidateToken(string jwtToken)
 {
     try
     {
         using (var ctx = new GreetNGroupContext())
         {
             var userID         = GetUserIDFromToken(jwtToken);
             var retrievedToken = ctx.JWTTokens.Where(j => j.Token == jwtToken)
                                  .Where(j => j.UserId == userID)
                                  .First();
             if (retrievedToken != null)
             {
                 retrievedToken.isValid          = false;
                 ctx.Entry(retrievedToken).State = EntityState.Modified;
                 ctx.SaveChanges();
                 return(true);
             }
             return(false);
         }
     }
     catch
     {
         return(false);
     }
 }
Esempio n. 2
0
 public Attendance UpdateAttendance(Attendance updatedAtendance)
 {
     using (var _db = new GreetNGroupContext())
     {
         _db.Entry(updatedAtendance).State = EntityState.Modified;
         _db.SaveChanges();
         return(updatedAtendance);
     }
 }
Esempio n. 3
0
        /// <summary>
        /// The following region handles updating user information within the database
        /// </summary>
        #region Update User Information

        // Updates user by replacing user object in database with new user object with updated fields
        public bool UpdateUser(User updatedUser)
        {
            try
            {
                using (var ctx = new GreetNGroupContext())
                {
                    ctx.Entry(updatedUser).State = EntityState.Modified;
                    ctx.SaveChanges();
                    return(true);
                }
            }
            catch (ObjectDisposedException od)
            {
                _gngLoggerService.LogGNGInternalErrors(od.ToString());
                return(false);
            }
        }