public Tuple <bool, Guid> IsUserValid(LoginDetails loginDetails) { var storedCredential = _context.UserCredentials.FirstOrDefault(x => x.UserID.Equals(loginDetails.UserID)); if (storedCredential != null) { if (storedCredential.Password.Equals(loginDetails.Password.GetHash())) { var sessionID = Guid.NewGuid(); var session = _context.Sessions.FirstOrDefault(x => x.UserID.Equals(loginDetails.UserID)); // creating a session if (session == null) { _context.Sessions.Add(new Session() { UserID = loginDetails.UserID, SessionID = sessionID }); _context.SaveChanges(); return(new Tuple <bool, Guid>(true, sessionID)); } } } return(new Tuple <bool, Guid>(false, Guid.Empty)); }
public IActionResult ClearData() { _dbContext.Users.Clear(); _dbContext.UserCredentials.Clear(); _dbContext.Teams.Clear(); _dbContext.Assets.Clear(); _dbContext.Sessions.Clear(); _dbContext.SaveChanges(); return(Ok()); }