Moved enums to a dedicated namespace and updated references across the codebase. Renamed the `Info` field in the `Interaction` entity to `Info1`, including necessary migrations and UI adjustments. These changes improve the organization and consistency of the codebase.
39 lines
1.1 KiB
C#
39 lines
1.1 KiB
C#
using FoodsharingSiegen.Contracts.Entity;
|
|
using FoodsharingSiegen.Contracts.Enums;
|
|
|
|
namespace FoodsharingSiegen.Contracts.Helper
|
|
{
|
|
/// <summary>
|
|
/// The entity extensions class (a. beging, 08.04.2022)
|
|
/// </summary>
|
|
public static class EntityExtensions
|
|
{
|
|
#region Public Method IsAdmin
|
|
|
|
/// <summary>
|
|
/// Describes whether is admin
|
|
/// </summary>
|
|
/// <param name="user">The user</param>
|
|
/// <returns>The bool</returns>
|
|
public static bool IsAdmin(this User user) => user.Type == UserType.Admin;
|
|
|
|
#endregion
|
|
|
|
#region Public Method IsInGroup
|
|
|
|
/// <summary>
|
|
/// Describes whether is in group
|
|
/// </summary>
|
|
/// <param name="user">The user</param>
|
|
/// <param name="groups">The groups</param>
|
|
/// <returns>The bool</returns>
|
|
public static bool IsInGroup(this User user, params UserGroup[] groups)
|
|
{
|
|
if (user.Type == UserType.Admin) return true;
|
|
if (groups.Any(x => user.GroupsList.Contains(x))) return true;
|
|
return false;
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
} |