/// <summary> /// Create multiple new cohorts /// </summary> /// <param name="cohorts">new cohorts to create</param> /// <returns></returns> //public async Task<string[]> CreateCohorts(IEnumerable<Cohort> cohorts) //{ // try // { // var result = await Task.WhenAll(from c in cohorts select CreateCohort()); //TODO: add cohort as parameter // return result; // } // catch (Exception ex) // { // throw; // } //} /// <summary> /// Update a single cohort /// </summary> /// <returns></returns> public async Task<string> UpdateCohort(CohortService cs, Cohort cohort) { //var c = new CohortService(Session["access_token"].ToString()); //var cohort = new Cohort(); //var random = new Random(); //cohort.id = "2012gd-cae52ab2-26f7-11e2-8acf-02786562673b"; //cohort.educationOrgId = "2012dh-836f96e7-0b25-11e2-985e-024775596ac8"; //cohort.cohortIdentifier = "ACC-" + DateTime.Now.Ticks.ToString().Substring(0,8); //cohort.cohortType = SlcClient.Enum.CohortType.ExtracurricularActivity; var result = await cs.Update(cohort); return result.ToString(); }
/// <summary> /// Update a single cohort /// </summary> /// <returns>result of the update</returns> public async Task<Result> UpdateCohort(CohortService cs, Cohort cohort) { try { var userSession = (UserSession)Session[INBLOOM_USER_SESSION]; //user session has edOrgId == null but we need edOrgId to update a cohort if (userSession != null && userSession.edOrgId != null && userSession.edOrgId != "") cohort.educationOrgId = userSession.edOrgId; else cohort.educationOrgId = CURRENT_ED_ORG_ID; var response = await cs.Update(cohort); var result = new Result { completedSuccessfully = response.StatusCode == HttpStatusCode.NoContent, objectActionResult = GlobalHelper.GetActionResponseResult(cohort.id, cohort.cohortIdentifier, response, HttpStatusCode.NoContent) }; return result; } catch (Exception e) { throw; } }