public IHttpActionResult CreateRootInstance(int id, EAV.Store.IStoreInstance anInstance) { try { return(Ok <EAV.Store.IStoreInstance>(instanceClient.CreateRootInstance(anInstance, ContainerID.GetValueOrDefault(), id))); } catch (Exception ex) { return(InternalServerError(ex)); } }
public void CreateRootInstance() { EAV.Store.Clients.IInstanceStoreClient client = factory.Create <EAV.Store.Clients.IInstanceStoreClient>(); int subjectID = SelectRandomItem(this.DbContext.Subjects).Subject_ID; int containerID = SelectRandomItem(this.DbContext.Containers.Where(it => it.Parent_Container_ID == null)).Container_ID; EAV.Store.IStoreInstance instance = client.CreateRootInstance(new EAVStoreLibrary.StoreInstance(), containerID, subjectID); Assert.IsNotNull(instance, "Failed to create instance for container ID {0} and subject ID {1}.", containerID, subjectID); ResetDatabaseContext(); var dbInstance = this.DbContext.Instances.SingleOrDefault(it => it.Instance_ID == instance.InstanceID); Assert.IsNotNull(dbInstance, String.Format("Failed to retrieve instance ID {0} from the database.", instance.InstanceID)); Assert.IsNull(dbInstance.Parent_Instance_ID, "Instance has parent reference defined when it should not."); }