Я знаю, что вопрос кажется легким, но я хотел узнать, есть ли лучший способ, чем сделать
if (partner.Type == "value" Или value2 или value3)
Может бытьс аннотациями данных?
это моя сущность POCO
/// <summary>
/// Partner Entity
/// </summary>
[SharedCosmosCollection("shared")]
public class Partner : ISharedCosmosEntity
{
/// <summary>
/// Partner id
/// </summary>
[JsonProperty("Id")]
public string Id { get; set; }
/// <summary>
/// Partner name
/// </summary>
public string PartnerName { get; set; }
/// <summary>
/// Partner contact name
/// </summary>
public string PartnerContact { get; set; }
/// <summary>
/// Partner contact phone
/// </summary>
public string PartnerPhone { get; set; }
/// <summary>
/// Partner contact Office 365 domain
/// </summary>
public string PartnerDomain { get; set; }
/// <summary>
/// Partner type, silver, gold or platinum
/// </summary>
public string PartnerType { get; set; }
/// <summary>
/// Partner start date
/// </summary>
public DateTime StartDate { get; set; }
/// <summary>
/// Partner end date
/// </summary>
public DateTime EndDate { get; set; }
/// <summary>
/// Parter enabled
/// </summary>
public bool Enabled { get; set; }
[CosmosPartitionKey]
public string CosmosEntityName { get; set; }
}
а это мой контроллер
[HttpPost]
public async Task<IHttpActionResult> AddPartner([FromBody]Partner partner)
{
var telemetry = new TelemetryClient();
try
{
var partnerStore = CosmosStoreHolder.Instance.CosmosStorePartner;
if (!ModelState.IsValid)
{
return BadRequest(ModelState);
}
var added = await partnerStore.AddAsync(partner);
return Ok(added);
}
catch (Exception ex)
{
string guid = Guid.NewGuid().ToString();
var dt = new Dictionary<string, string>
{
{ "Error Lulo: ", guid }
};
telemetry.TrackException(ex, dt);
return BadRequest("Error Lulo: " + guid);
}
}