namespace MyOffice.Services.Account;

using Data.Models.Accounts;

/// <summary>
/// Account access checks shared by service mutations (motions, settings, invites).
/// </summary>
public static class AccountAcl
{
	public static AccountAccess? GetUserAccess(Account account, Guid userId) =>
		account.AccessRights?.FirstOrDefault(x => x.UserId == userId);

	public static bool CanWrite(Account account, Guid userId) =>
		GetUserAccess(account, userId)?.IsAllowWrite == true;

	public static bool CanManage(Account account, Guid userId) =>
		GetUserAccess(account, userId)?.IsAllowManage == true;
}
