in src/Web/Controllers/OrderController.cs [140:218]
public async Task<IActionResult> LabelOrder(
OrderViewModel viewModel,
LabelSource labelSource,
LabelObjectType labelObjectType,
LabelState labelStatus,
LabelReasonCodes labelReasonCode,
string effectiveStartDate,
string effectiveEndDate)
{
var order = await GetOrder(viewModel.OrderNumber);
if (order == null)
{
return BadRequest("No such order found for this user.");
}
#region Fraud Protection Service
string labelObjectId;
switch (labelObjectType)
{
case LabelObjectType.Purchase:
labelObjectId = order.RiskPurchase.PurchaseId;
break;
case LabelObjectType.Account:
labelObjectId = order.RiskPurchase.User.UserId;
break;
case LabelObjectType.Email:
labelObjectId = order.RiskPurchase.User.Email;
break;
case LabelObjectType.PI:
labelObjectId = order.RiskPurchase.PaymentInstrumentList[0].MerchantPaymentInstrumentId;
break;
default:
throw new InvalidOperationException("Label object type not supported: " + labelObjectType);
}
var label = new Label
{
LabelObjectType = labelObjectType.ToString(),
LabelObjectId = labelObjectId,
LabelSource = labelSource.ToString(),
LabelReasonCodes = labelReasonCode.ToString(),
LabelState = labelStatus.ToString(),
EventTimeStamp = DateTimeOffset.Now,
Processor = "Fraud Protection sample site",
};
if(!String.IsNullOrEmpty(effectiveStartDate) )
{
DateTimeOffset labelEffectiveStartDate;
if (DateTimeOffset.TryParse(effectiveStartDate, out labelEffectiveStartDate))
{
label.EffectiveStartDate = labelEffectiveStartDate;
}
}
if (!String.IsNullOrEmpty(effectiveEndDate))
{
DateTimeOffset labelEffectiveEndDate;
if (DateTimeOffset.TryParse(effectiveEndDate, out labelEffectiveEndDate))
{
label.EffectiveEndDate = labelEffectiveEndDate;
}
}
if (labelObjectType == LabelObjectType.Purchase)
{
label.Amount = order.Total;
label.Currency = order.RiskPurchase?.Currency;
}
var correlationId = _fraudProtectionService.NewCorrelationId;
var response = await _fraudProtectionService.PostLabel(label, correlationId);
var fraudProtectionIO = new FraudProtectionIOModel(correlationId, label, response, "Label");
TempData.Put(FraudProtectionIOModel.TempDataKey, fraudProtectionIO);
#endregion
return View("LabelDone");
}