DD.WellWorkover.Cloud/AsbCloudWebApi/Extensions.cs
2021-08-17 13:03:17 +05:00

31 lines
787 B
C#

using AsbCloudDb.Model;
using System.Security.Claims;
namespace AsbCloudWebApi
{
public static class Extensions
{
public static int? GetCompanyId(this ClaimsPrincipal user)
{
var claimIdCompany = user.FindFirst(nameof(User.IdCompany));
if (claimIdCompany is null)
return null;
return int.TryParse(claimIdCompany.Value, out int uid)
? uid
: null;
}
public static int? GetUserId(this ClaimsPrincipal user)
{
var userId = user.FindFirst(nameof(User.Id));
if (userId is null)
return null;
return int.TryParse(userId.Value, out int uid)
? uid
: null;
}
}
}