Interface IChoiceService
Represents the choice API service.
Namespace: Relativity.Testing.Framework.Api.Services
Assembly: Relativity.Testing.Framework.Api.dll
Syntax
public interface IChoiceService
  Examples
_choiceService = relativityFacade.Resolve<IChoiceService>();
  Methods
| Improve this Doc View SourceCreate(Int32, Choice)
Creates the specified choice.
Declaration
Choice Create(int workspaceId, Choice entity)
  Parameters
| Type | Name | Description | 
|---|---|---|
| System.Int32 | workspaceId | The Artifact ID of the workspace where you want to add the new choice, or use -1 to indicate the admin-level context.  | 
      
| Choice | entity | The entity to create.  | 
      
Returns
| Type | Description | 
|---|---|
| Choice | The created entity.  | 
      
Examples
var workspaceId = 1015427;
var fieldName = "Some Field Name";
var existingField = relativityFacade.Resolve<IFieldService>().Get<MultipleChoiceField>(workspaceId, fieldName);
var entity = new Choice
{
	Name = Randomizer.GetString(),
	Field = existingField
};
var createdChoice = _choiceService.Create(workspaceId, entity);
  
    |
    Improve this Doc
  
  
    View Source
  
  
  Delete(Int32, Int32)
Deletes the choice by ID.
Declaration
void Delete(int workspaceId, int entityId)
  Parameters
| Type | Name | Description | 
|---|---|---|
| System.Int32 | workspaceId | The Artifact ID of the workspace where you want to delete the choice, or use -1 to indicate the admin-level context.  | 
      
| System.Int32 | entityId | The artifact ID of the choice.  | 
      
Examples
var workspaceId = 1015427;
var choiceArtifactId = 1;
_choiceService.Delete(workspaceId, choiceArtifactId);
  
    |
    Improve this Doc
  
  
    View Source
  
  
  Get(Int32, Int32)
Gets the choice by the specified ID.
Declaration
Choice Get(int workspaceId, int entityId)
  Parameters
| Type | Name | Description | 
|---|---|---|
| System.Int32 | workspaceId | The Artifact ID of the workspace where you want to get the choice, or use -1 to indicate the admin-level context.  | 
      
| System.Int32 | entityId | The artifact ID of the choice.  | 
      
Returns
| Type | Description | 
|---|---|
| Choice | The Choice entity or null.  | 
      
Examples
var workspaceId = 1015427;
var choiceArtifactId = 1;
var choice =_choiceService.Get(workspaceId, choiceArtifactId);
  
    |
    Improve this Doc
  
  
    View Source
  
  
  GetAll(Int32, String, String)
Gets all choices for particular object field.
Declaration
IEnumerable<Choice> GetAll(int workspaceId, string objectTypeName, string fieldName)
  Parameters
| Type | Name | Description | 
|---|---|---|
| System.Int32 | workspaceId | The workspace ID.  | 
      
| System.String | objectTypeName | Name of the object type.  | 
      
| System.String | fieldName | Name of the field.  | 
      
Returns
| Type | Description | 
|---|---|
| System.Collections.Generic.IEnumerable<Choice> | The collection of Choice entities.  | 
      
Examples
var workspaceId = 1015427;
var objectTypeName = "SomeObjectTypeName";
var fieldName = "SomeFieldName";
var choices =_choiceService.GetAll(workspaceId, objectTypeName, fieldName);
  
    |
    Improve this Doc
  
  
    View Source
  
  
  Require(Int32, Choice)
Requires the specified choice.
- If [ArtifactID](https://relativitydev.github.io/relativity.testing.framework/api/Relativity.Testing.Framework.Models.Artifact.html#Relativity_Testing_Framework_Models_Artifact_ArtifactID) property of 
entityhas positive value, gets entity by ID and updates it. - If [Name](https://relativitydev.github.io/relativity.testing.framework/api/Relativity.Testing.Framework.Models.NamedArtifact.html#Relativity_Testing_Framework_Models_NamedArtifact_Name) and ObjectType(https://relativitydev.github.io/relativity.testing.framework/api/Relativity.Testing.Framework.Models.Choice.html#Relativity_Testing_Framework_Models_Choice_ObjectType) and [Field](https://relativitydev.github.io/relativity.testing.framework/api/Relativity.Testing.Framework.Models.Choice.html#Relativity_Testing_Framework_Models_Choice_Field) name properties of 
entityhave a value, gets entity by name and updates it if it exists. - Otherwise creates a new entity using Relativity.Testing.Framework.Api.Strategies.ICreateWorkspaceEntityStrategy`1.
 
Declaration
Choice Require(int workspaceId, Choice entity)
  Parameters
| Type | Name | Description | 
|---|---|---|
| System.Int32 | workspaceId | The Artifact ID of the workspace where you want to require choice, or use -1 to indicate the admin-level context.  | 
      
| Choice | entity | The entity to require.  | 
      
Returns
| Type | Description | 
|---|---|
| Choice | The entity required.  | 
      
Examples
var workspaceId = 1015427;
var fieldName = "Some Field Name";
var existingChoiceArtifactId = 1;
var existingField = relativityFacade.Resolve<IFieldService>().Get<MultipleChoiceField>(workspaceId, fieldName);
var entityToUpdateByArtifactId = new Choice
{
	ArtifactId = existingChoiceArtifactId,
	Field = existingField,
	Name = "Some Updated Choice Name"
};
var updatedByArtifactIdChoice = _choiceService.Require(workspaceId, entityToUpdateByArtifactId); // Will get the choice field by ArtifactId, update it and return updated choice.
var entityToUpdateByNameObjectTypeAndField = new Choice
{
	Field = existingField,
	Name = "Some Existing Choice Name",
	ObjectType = new NamedArtifact { Name = "Some Object Type Name },
	Color = ChoiceColor.Blue
};
var updatedByNameObjectTypeAndField = _choiceService.Require(workspaceId, entityToUpdateByNameObjectTypeAndField); // Will get the choice field by Name, update it and return updated choice.
var entityToCreate = new Choice
{
	Name = Randomizer.GetString(),
	Field = existingField
};
var createdEntity =_choiceService.Require(workspaceId, entityToCreate); // Will create new choice entity and return it.
  
    |
    Improve this Doc
  
  
    View Source
  
  
  Update(Int32, Choice)
Updates the specified choice.
Declaration
void Update(int workspaceId, Choice entity)
  Parameters
| Type | Name | Description | 
|---|---|---|
| System.Int32 | workspaceId | The Artifact ID of the workspace where you want to update the choice, or use -1 to indicate the admin-level context.  | 
      
| Choice | entity | The entity to update.  | 
      
Examples
var workspaceId = -1;
var toUpdate = _choiceService.Get(workspaceId, someExistingChoiceArtifactId);
toUpdate.Name = "Some Updated Choice Name";
toUpdate.Order = 100;
toUpdate.Color = ChoiceColor.Orange;
_choiceService.Update(workspaceId, toUpdate);