/// <summary> /// AJAX to this method to create brand new groups with students /// </summary> /// <param name="obj"></param> /// <returns></returns> public async Task<string> CreateGroup(CohortActionObject obj) { try { var cs = new CohortService(Session["access_token"].ToString()); var cohortId = await CreateCohort(cs, obj.cohort); //1) create the cohort first and retrieve the Id of the new cohort var studentsAssociations = CreateMultipleAssociation(cs, cohortId, obj.studentsToCreate); //2) start creating student cohort association var cohortCustom = cs.CreateCohortCustom(cohortId, JsonConvert.SerializeObject(obj.custom)); //3) initial populate of the cohort custom entity await Task.WhenAll(studentsAssociations, cohortCustom); return cohortId; } catch (Exception e) { //handle throw; } }
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; }