/// <summary>
 /// Update cohort custom entity
 /// </summary>
 /// <param name="obj">Cohort data to update</param>
 /// <param name="cs">Cohort Service object to update</param>
 /// <returns></returns>
 public static Task<HttpResponseMessage> UpdateCustom(CohortActionObject obj, CohortService cs)
 {
     var custom = obj.custom;
     if (custom == null) custom = new CohortCustom { lastModifiedDate = DateTime.UtcNow };
     else custom.lastModifiedDate = DateTime.UtcNow;
     var cohortCustom = cs.UpdateCohortCustom(obj.cohort.id, JsonConvert.SerializeObject(custom));
     return cohortCustom;
 }
 public static Task<HttpResponseMessage> CreateCustom(CohortCustom custom, CohortService cs)
 {
     if (custom == null) custom = new CohortCustom { lastModifiedDate = DateTime.UtcNow };
     else custom.lastModifiedDate = DateTime.UtcNow;
     var cohortCustom = cs.CreateCohortCustom(custom.cohortId, JsonConvert.SerializeObject(custom));
     return cohortCustom;
 }
        /// <summary>
        /// Update the Result object after custom has been updated through inBloom
        /// </summary>
        /// <param name="cohortResult">Result object to update</param>
        /// <param name="cohortCustom">the inBloom response message</param>
        /// <param name="successStatus">HttpStatusCode that indicates a successful response</param>
        public static void ProcessCustomResult(Result cohortResult, Task<HttpResponseMessage> m, HttpStatusCode successStatus, 
                                                CohortCustom cohortCustom = null, CohortService cs = null)
        {
            //If not found meaning cohort doesn't have a custom entity created yet
            if (m.Result.StatusCode == HttpStatusCode.NotFound)
            {
                var result = CreateCustom(cohortCustom, cs);
                ProcessCustomResult(cohortResult, result, HttpStatusCode.Created);
            }
            else
            {
                //Found the custom entity, process response from the custom entity update
                var customResult = GlobalHelper.GetActionResponseResult(cohortResult.objectActionResult.objectId,
                                                cohortResult.objectActionResult.objectName, m.Result, successStatus);
                if (m.Result.StatusCode != successStatus)
                    cohortResult.completedSuccessfully = false;

                cohortResult.customActionResult = customResult;
            }           
        }