/// <summary> /// Performs object type seed /// </summary> /// <typeparam name="TDbCtx"></typeparam> /// <param name="context"></param> /// <param name="filter">Fully qualified namespaces to be taken into account when auto seeding object types</param> private static void SeedObjectTypes <TDbCtx>(TDbCtx context, IEnumerable <string> filter = null) where TDbCtx : ApplicationDbContext { //this is an automated seed, so ignore scenarios where context is not an app context if (context == null) { return; } foreach (var type in BaseObjectTypeIdentifierExtensions.GetRegisteredBaseSubclassingTypes()) { if (VerifyObjectType(type, filter)) { //context.ObjectTypes.AddOrUpdate(new ObjectType { Name = type.ToString(), Uuid = ObjectTypeExtensions.GetTypeUuid(type) }); if (!context.ObjectTypes.Any(o => o.Uuid == BaseObjectTypeIdentifierExtensions.GetTypeIdentifier(type))) { context.ObjectTypes.Add(new ObjectType { Name = type.ToString(), Uuid = BaseObjectTypeIdentifierExtensions.GetTypeIdentifier(type) }); } } } }
/// <summary> /// Whether or not request can perform a update action /// </summary> /// <returns></returns> protected virtual async Task <bool> IsCrudPrivilegeGrantedForUpdateAsync(DbContext dbCtx) { // Check if permission is required if (!IsCrudPrivilegeRequiredForUpdate) { return(true); } var roles = await GetUserRoles(dbCtx, Cartomatic.Utils.Identity.GetUserGuid()); // Check if user roles have required permission return(roles.Any(r => r.Privileges?.Any(p => p.TypeId == BaseObjectTypeIdentifierExtensions.GetTypeIdentifier(typeof(T)) && p.Update == true) == true)); }