public static bool HasEqualMembership(this IUser user, ProjectMembership membership) { if (user is null) { throw new ArgumentNullException(nameof(user)); } if (membership is null) { throw new ArgumentNullException(nameof(membership)); } return(new ProjectMembershipComparer().Equals(user.ProjectMembership(membership.ProjectId), membership)); }
public static TUser UpdateProjectMembership <TUser>(this TUser user, ProjectMembership membership) where TUser : class, IUser { if (user is null) { throw new ArgumentNullException(nameof(user)); } if (membership is null) { throw new ArgumentNullException(nameof(membership)); } var existingMembership = user.ProjectMemberships.FirstOrDefault(m => m.ProjectId == membership.ProjectId); existingMembership.Role = membership.Role; existingMembership.Properties = membership.Properties ?? new Dictionary <string, string>(); return(user); }