public String AdminObjectToJson(AdminCls obj) { return new JavaScriptSerializer().Serialize(obj); }
public void AddAggregateFlagIntoEducationOrganization(User _user, String EducationOrganizationId, AggregateCls[] _aggregateFlagCls) { try { AdminCls _adminCls = GetFlagListForAdminUser(EducationOrganizationId, _user.ExternalId); Temp _flagListPrivateAdminCustom = null; if (_adminCls == null) { // no data present in organization Temp[] _temp = new Temp[1]; _temp[0] = new Temp(); _temp[0].AggregateFlagList = _aggregateFlagCls; _temp[0].UserId = _user.ExternalId; _temp[0].IsAdmin = _user.IsAdminUser; _adminCls = new AdminCls(); _adminCls.AdminList = _temp; PutCustomForAdmin(EducationOrganizationId, _adminCls); } else { // data is present need to add new Temp[] _temp = _adminCls.AdminList; bool UserExist = false; int Index = 0; int UserIndex = 0; for (int i = 0; i < _temp.Count(); i++) { if (_temp[i].UserId == _user.ExternalId) { // user record exist UserExist = true; Index = i; break; } } if (UserExist) { Temp _flagForEdit = _temp[Index]; AggregateCls[] _flagClsForEdit = _flagForEdit.AggregateFlagList; if (_flagClsForEdit != null) { AggregateCls[] _flagClsNew = new AggregateCls[_flagClsForEdit.Count() + 1]; for (int i = 0; i < _flagClsForEdit.Count(); i++) { _flagClsNew[i] = new AggregateCls(); _flagClsNew[i] = _flagClsForEdit[i]; } _flagClsNew[_flagClsForEdit.Count()] = new AggregateCls(); _flagClsNew[_flagClsForEdit.Count()] = _aggregateFlagCls[0]; _flagForEdit.AggregateFlagList = _flagClsNew; } else { _flagForEdit.AggregateFlagList = _aggregateFlagCls; } _temp[Index] = _flagForEdit; _adminCls.AdminList = _temp; PutCustomForAdmin(EducationOrganizationId, _adminCls); } else { // new admin user Temp[] _tempForNew = new Temp[_temp.Count() + 1]; for (int i = 0; i < _temp.Count(); i++) { _tempForNew[i] = new Temp(); _tempForNew[i] = _temp[i]; } Temp _tempAdmin = new Temp(); _tempAdmin.IsAdmin = _user.IsAdminUser; _tempAdmin.UserId = _user.ExternalId; _tempAdmin.AggregateFlagList = _aggregateFlagCls; _tempForNew[_tempForNew.Count() - 1] = new Temp(); _tempForNew[_tempForNew.Count() - 1] = _tempAdmin; _adminCls.AdminList = _tempForNew; PutCustomForAdmin(EducationOrganizationId, _adminCls); } } } catch (Exception Ex) { } }
public void PutCustomForAdmin(String EducationOrganizationId, AdminCls _obj) { try { String Result = AdminObjectToJson(_obj); RestApiHelper.CallApiForCustomPut("educationOrganizations/" + EducationOrganizationId + "/custom", this.AccessToken, Result); } catch (Exception Ex) { } }