DD.WellWorkover.Cloud/AsbCloudApp/Services/IUserSettingsRepository.cs
2024-08-19 10:01:07 +05:00

56 lines
1.9 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using System.Threading;
using System.Threading.Tasks;
namespace AsbCloudApp.Services;
/// <summary>
/// репозиторий для личных настроек пользователя
/// </summary>
public interface IUserSettingsRepository
{
/// <summary>
/// код ошибки: ключ не найден
/// </summary>
public const int ErrorKeyNotFound = -1;
/// <summary>
/// код ошибки: ключ уже занят
/// </summary>
public const int ErrorKeyIsUsed = -2;
/// <summary>
/// Получить настройки по ключу для пользователя
/// </summary>
/// <param name="userId"></param>
/// <param name="key"></param>
/// <param name="token"></param>
/// <returns></returns>
Task<System.Text.Json.JsonDocument?> GetOrDefaultAsync(int userId, string key, CancellationToken token);
/// <summary>
/// Добавить или изменить настройки с ключем для пользователя
/// </summary>
/// <param name="userId"></param>
/// <param name="key"></param>
/// <param name="value"></param>
/// <param name="token"></param>
/// <returns></returns>
Task<int> UpsertAsync(int userId, string key, System.Text.Json.JsonDocument value, CancellationToken token);
/// <summary>
/// Удалить настройки с ключем для пользователя
/// </summary>
/// <param name="userId"></param>
/// <param name="key"></param>
/// <param name="token"></param>
/// <returns></returns>
Task<int> DeleteAsync(int userId, string key, CancellationToken token);
/// <summary>
/// Удалить ВСЕ настройки пользователя
/// </summary>
/// <param name="userId"></param>
/// <param name="token"></param>
/// <returns></returns>
Task<int> DeleteAsync(int userId, CancellationToken token);
}