CodeLiturgy.Dashboard/CodeLiturgy.Views/RazorUtils/DataUtil.cs

34 lines
825 B
C#
Raw Normal View History

2022-11-18 03:15:53 +03:00
using CodeLiturgy.Data.Application.Users;
using CodeLiturgy.Data.Auth;
2022-10-30 19:48:24 +03:00
using CodeLiturgy.Views.Models;
2022-10-27 20:13:02 +03:00
using Microsoft.AspNetCore.Mvc.ViewFeatures;
2022-10-30 19:48:24 +03:00
namespace CodeLiturgy.Views.Utils;
2022-10-27 20:13:02 +03:00
public static class DataUtil
{
public static ApplicationUserUnique GetUserViewData(this ViewDataDictionary viewData)
{
if (viewData[UserViewDataId] is ApplicationUserUnique user)
{
return user;
}
return null!;
}
public static IpInformation GetIpInformation(this ViewDataDictionary viewData)
{
if (viewData[IpViewStorage] is IpInformation ipInformation)
{
return ipInformation;
}
return null!;
}
public static string GetRootUrl(this ViewDataDictionary viewData)
{
return SessionConstants.CookieDomain;
}
}