DD.WellWorkover.Cloud/AsbCloudWebApi/Extensions.cs

20 lines
477 B
C#
Raw Normal View History

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-07-21 15:22:58 +05:00
var claimIdCompany = user.FindFirst(nameof(User.IdCompany));
if (claimIdCompany is null)
return null;
2021-07-21 15:22:58 +05:00
return int.TryParse(claimIdCompany.Value, out int uid)
? uid
: null;
}
}
}