/// <summary> /// Concludes execution of the Add card call after previous work has been completed. /// </summary> /// <param name="resultCode"> /// The ResultCode to set within the call response. /// </param> /// <exception cref="ArgumentNullException"> /// Parameter context cannot be null. /// </exception> public void Conclude(ResultCode resultCode) { try { Context.Log.Verbose("ResultCode when Conclude process begins: {0}.", resultCode); // If process succeeded, update internal data storage. AddCardResponse response = (AddCardResponse)Context[Key.Response]; if (resultCode == ResultCode.Created) { // Add the card. resultCode = AddCard(); if (resultCode == ResultCode.Created || resultCode == ResultCode.Success) { response.NewCardId = General.GuidFromInteger(((Card)Context[Key.Card]).Id); // If a new card was added, kick off confirmation process for unauthenticated users and add needed information to analytics. // TODO: AddCard() above returns ResultCode.Success. So the code below will not execute. Is it ok? if (resultCode == ResultCode.Created) { // Kick off confirmation process for unauthenticated users. bool createUnauthenticatedAccount = false; if (Context[Key.CreateUnauthenticatedAccount] != null) { createUnauthenticatedAccount = (bool)Context[Key.CreateUnauthenticatedAccount]; } if (createUnauthenticatedAccount == true) { IUsersDal usersDal = PartnerFactory.UsersDal(Context.Config); Task.Run(() => usersDal.CompleteUnauthenticatedUserSetUp((Guid)Context[Key.GlobalUserId])); } // Add analytics info. Context.Log.Verbose("Adding new card to analytics."); User user = (User)Context[Key.User]; Analytics.AddAddCardEvent(user.GlobalId, user.AnalyticsEventId, Guid.Empty, Context[Key.ReferrerId] as string); } // Queue deal claiming if set to do so. bool queueDealClaiming = false; if (Context[Key.QueueJob] != null) { queueDealClaiming = (bool)Context[Key.QueueJob]; } // Linking is only for First Data, but by the time execution reaches this part of the code, the card may need to be linked to CLO offers or // Burn offers, or both, but definitely at least one of them. Therefore, a job has to be scheduled to cover the relevant combination of CLO // and Burn offers. That Earn offers are not registered with First Data doesn't change this-- the filtering will have to occur as part of the job. if (queueDealClaiming == true) { QueueClaimingDeals(response); resultCode = ResultCode.JobQueued; } } } response.ResultSummary.SetResultCode(resultCode); RestResponder.BuildAsynchronousResponse(Context); } catch (Exception ex) { RestResponder.BuildAsynchronousResponse(Context, ex); } }