2021-05-12 16:03:14 +05:00
|
|
|
|
using AsbCloudDb.Model;
|
|
|
|
|
using System.Security.Claims;
|
|
|
|
|
|
|
|
|
|
namespace AsbCloudWebApi
|
|
|
|
|
{
|
|
|
|
|
public static class Extensions
|
|
|
|
|
{
|
2021-07-21 15:22:58 +05:00
|
|
|
|
public static int? GetCompanyId(this ClaimsPrincipal user)
|
2021-05-12 16:03:14 +05:00
|
|
|
|
{
|
2021-07-21 15:22:58 +05:00
|
|
|
|
var claimIdCompany = user.FindFirst(nameof(User.IdCompany));
|
|
|
|
|
if (claimIdCompany is null)
|
2021-05-12 16:03:14 +05:00
|
|
|
|
return null;
|
|
|
|
|
|
2021-07-21 15:22:58 +05:00
|
|
|
|
return int.TryParse(claimIdCompany.Value, out int uid)
|
2021-05-12 16:03:14 +05:00
|
|
|
|
? uid
|
|
|
|
|
: null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|