public Dictionary <string, object> CreateOrUpdate([FromUri] string contentType, [FromBody] Dictionary <string, object> newContentItem, [FromUri] int?id = null, [FromUri] string appPath = null) { Log.Add($"create or update type:{contentType}, id:{id}, path:{appPath}"); // if app-path specified, use that app, otherwise use from context var appId = GetAppIdFromPathOrContext_AndInitEavAndSerializer(appPath); // Check that this ID is actually of this content-type, // this throws an error if it's not the correct type var itm = id == null ? null : _entitiesController.GetEntityOrThrowError(contentType, id.Value); var perm = id == null ? Grants.Create : Grants.Update; PerformSecurityCheck(appId, contentType, perm, appPath == null ? Dnn.Module : null, App, itm); // Convert to case-insensitive dictionary just to be safe! newContentItem = new Dictionary <string, object>(newContentItem, StringComparer.OrdinalIgnoreCase); // Now create the cleaned up import-dictionary so we can create a new entity var cleanedNewItem = CreateEntityDictionary(contentType, newContentItem, appId); var userName = new DnnUser().IdentityToken; // try to create var currentApp = new App(new DnnTenant(PortalSettings), appId); //currentApp.InitData(false, new ValueCollectionProvider()); var publish = Factory.Resolve <IEnvironmentFactory>().PagePublisher(Log); currentApp.InitData(false, publish.IsEnabled(ActiveModule.ModuleID), Data.ConfigurationProvider); if (id == null) { currentApp.Data.Create(contentType, cleanedNewItem, userName); // Todo: try to return the newly created object return(null); } else { currentApp.Data.Update(id.Value, cleanedNewItem, userName); return(_entitiesController.Serializer.Prepare(currentApp.Data.List.One(id.Value))); } }