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 Temp[] GetFlagListOfStaffForAdminUser(User _user, String EducationOrganizationId, ListItem[] _schoolList)
        {
            Temp[] _temp = null;
            try
            {
                for (int i = 0; i < _schoolList.Count(); i++)
                {
                    Temp[] _tempStaff = null;
                    JArray _staffResponse = JArray.Parse(RestApiHelper.CallApi("schools/" + _schoolList[i].Value + "/teacherSchoolAssociations/teachers", this._accessToken));
                    if (_staffResponse != null)
                    {
                        String CustomLink = "";
                        _tempStaff = new Temp[_staffResponse.Count()];
                        for (int Index = 0; Index < _staffResponse.Count(); Index++)
                        {
                            JArray Links = JArray.Parse(_staffResponse[Index]["links"].ToString());
                            for (int j = 0; j < Links.Count; j++)
                            {
                                String Relation = _authenticateUser.GetStringWithoutQuote(Links[j]["rel"].ToString());
                                if (Relation.Equals("custom"))
                                {
                                    CustomLink = _authenticateUser.GetStringWithoutQuote(Links[j]["href"].ToString());
                                    Temp _response = GetCustomForStaff(CustomLink);
                                    _tempStaff[Index] = new Temp();
                                    _tempStaff[Index] = _response;
                                    break;
                                }
                            }

                            if (_temp == null)
                            {
                                _temp = new Temp[_tempStaff.Count()];
                                for (int j = 0; j < _tempStaff.Count(); j++)
                                {
                                    _temp[j] = new Temp();
                                    _temp[j] = _tempStaff[j];
                                }
                            }
                            else
                            {
                                // store _temp array into another
                                Temp[] _forTemp = new Temp[_temp.Count()];
                                for (int j = 0; j < _temp.Count(); j++)
                                {
                                    _forTemp[j] = new Temp();
                                    _forTemp[j] = _temp[j];
                                }

                                // get newly added staff temp
                                _temp = new Temp[_tempStaff.Count() + _temp.Count()];
                                for (int j = 0; j < _tempStaff.Count(); j++)
                                {
                                    _temp[j] = new Temp();
                                    _temp[j] = _tempStaff[j];
                                }

                                // get previous staff
                                int k = 0;
                                for (int j = _tempStaff.Count(); j < _tempStaff.Count() + _forTemp.Count(); j++)
                                {
                                    _temp[j] = new Temp();
                                    _temp[j] = _forTemp[k];
                                    k = k + 1;
                                }
                            }

                        }

                    }
                }

                // check for the blank
                int totalBlank = 0;
                for (int i = 0; i < _temp.Count(); i++)
                {
                    if (_temp[i] == null)
                        totalBlank = totalBlank + 1;
                }

                Temp[] _returnTemp = new Temp[_temp.Count() - totalBlank];
                int p = 0;
                for (int i = 0; i < _temp.Count(); i++)
                {
                    if (_temp[i] != null)
                    {
                        _returnTemp[p] = new Temp();
                        _returnTemp[p] = _temp[i];
                        p++;

                    }
                }

                return _returnTemp;
            }
            catch (InRowChangingEventException Ex)
            {
                return null;
            }
        }