using System.Diagnostics.CodeAnalysis;
using Microsoft.AspNetCore.Mvc;
using OliverBooth.Data.Web;
using ISession = OliverBooth.Data.Web.ISession;
namespace OliverBooth.Services;
public interface ISessionService
{
///
/// Creates a new session for the specified user.
///
/// The HTTP request.
/// The user.
/// The newly-created session.
///
/// is .
/// -or-
/// is .
///
ISession CreateSession(HttpRequest request, IUser user);
///
/// Deletes the specified session.
///
/// The session to delete.
/// is .
void DeleteSession(ISession session);
///
/// Deletes the client's session cookie.
///
/// The response to edit.
/// is .
IActionResult DeleteSessionCookie(HttpResponse response);
///
/// Saves a session cookie to the client's browser.
///
/// The response to edit.
/// The session to write.
///
/// is .
/// -or-
/// is .
///
void SaveSessionCookie(HttpResponse response, ISession session);
///
/// Attempts to find the user associated with the client's current request.
///
/// The HTTP request.
/// The response to edit.
///
/// When this method returns, contains the user with the specified request, if the user is found; otherwise,
/// .
///
///
/// if a user is found; otherwise, .
///
///
/// is .
/// -or-
/// is .
///
bool TryGetCurrentUser(HttpRequest request, HttpResponse response, [NotNullWhen(true)] out IUser? user);
///
/// Attempts to find a session with the specified ID.
///
/// The session ID.
///
/// When this method returns, contains the session with the specified ID, if the session is found; otherwise,
/// .
///
///
/// if a session with the specified ID is found; otherwise, .
///
bool TryGetSession(Guid sessionId, [NotNullWhen(true)] out ISession? session);
///
/// Attempts to find the session associated with the HTTP request.
///
/// The HTTP request.
///
/// When this method returns, contains the session with the specified request, if the user is found; otherwise,
/// .
///
/// if the session was found; otherwise, .
/// is .
bool TryGetSession(HttpRequest request, [NotNullWhen(true)] out ISession? session);
///
/// Validates the session with the incoming HTTP request.
///
/// The HTTP request.
/// The session.
/// if the session is valid; otherwise, .
///
/// is .
/// -or-
/// is .
///
bool ValidateSession(HttpRequest request, ISession session);
}