/// <inheritdoc /> public ResourceModel Save(ResourceModel model) { var converter = new ModelToResourceConverter(Graph, Serialization); var resourcesToSave = new HashSet <Resource>(); // Get or create resource converter.FromModel(model, resourcesToSave); // Save all created or altered resources foreach (var resourceToSave in resourcesToSave) { Graph.Save(resourceToSave); } return(model); }
public ResourceModel Save(ResourceModel model) { return(ExecuteCall <ResourceModel>(delegate { var converter = new ModelToResourceConverter(Graph, Serialization); var resourcesToSave = new HashSet <Resource>(); // Get or create resource var instance = converter.FromModel(model, resourcesToSave); // Save all created or altered resources foreach (var resourceToSave in resourcesToSave) { Graph.Save(resourceToSave); } return new ResourceToModelConverter(TypeTree, Serialization).GetDetails(instance); })); }
public ResourceModel Update(string idString, ResourceModel model) { return(ExecuteCall <ResourceModel>(delegate { var resourcesToSave = new HashSet <Resource>(); var converter = new ModelToResourceConverter(Graph, Serialization); Resource resource; if (!long.TryParse(idString, out var id) || (resource = Graph.Get(id)) == null) { return RequestResult <ResourceModel> .NotFound($"Resource {idString} not found!"); } // Get or create resource converter.FromModel(model, resourcesToSave, resource); // Save all created or altered resources foreach (var resourceToSave in resourcesToSave) { Graph.Save(resourceToSave); } return new ResourceToModelConverter(TypeTree, Serialization).GetDetails(resource); }));