public static async Task <bool> LogoutUser(string username, string session)
        {
            using (Contexts.SMEManagementContext db = new Contexts.SMEManagementContext())
            {
                Models.Authentication.LoggedUser loggedUser = await
                                                                  (from current in db.LoggedUsers.Include(".User")
                                                                  where current.User.Name == username &&
                                                                  current.Session == session
                                                                  select current).FirstOrDefaultAsync();

                if (loggedUser != null)
                {
                    db.LoggedUsers.Remove(loggedUser);
                    await db.SaveChangesAsync();

                    return(true);
                }

                return(false);
            }
        }
        public static async Task <bool> LoginUser(string username, string session, string refreshToken)
        {
            using (Data.Contexts.SMEManagementContext db = new Contexts.SMEManagementContext())
            {
                Models.Authentication.LoggedUser loggedUser = await
                                                                  (from current in db.LoggedUsers.Include(".User")
                                                                  where current.User.Name == username
                                                                  select current).FirstOrDefaultAsync();

                if (loggedUser == null)
                {
                    Models.Authentication.User user = await
                                                          (from current in db.Users
                                                          where current.Name == username
                                                          select current).FirstOrDefaultAsync();

                    loggedUser = new Models.Authentication.LoggedUser()
                    {
                        User         = user,
                        RefreshToken = refreshToken,
                        Session      = session,
                        LastAccess   = DateTime.Now,
                        ExpiresAt    = DateTime.Now.AddMinutes(30)
                    };

                    await db.LoggedUsers.AddAsync(loggedUser);
                }
                else
                {
                    loggedUser.RefreshToken = refreshToken;
                    loggedUser.Session      = session;
                    loggedUser.LastAccess   = DateTime.Now;
                    loggedUser.ExpiresAt    = DateTime.Now.AddMinutes(30);
                }

                await db.SaveChangesAsync();

                return(true);
            }
        }