using FoodsharingSiegen.Contracts.Entity; using FoodsharingSiegen.Contracts.Enums; namespace FoodsharingSiegen.Contracts.Helper { /// /// The entity extensions class (a. beging, 08.04.2022) /// public static class EntityExtensions { #region Public Method IsAdmin /// /// Describes whether is admin /// /// The user /// The bool public static bool IsAdmin(this User user) => user.Type == UserType.Admin; #endregion #region Public Method IsInGroup /// /// Describes whether is in group /// /// The user /// The groups /// The bool 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 } }