Пример #1
0
        public static void UpdateGroup(int group_id, string name)
        {
            if (!CanUpdate() || group_id <= 9)
            {
                throw new AccessDeniedException();
            }

            DBGroup.Update(group_id, name);
        }
Пример #2
0
        public static void UpdatePartner(int PartnerId, PrimaryKeyId contactUid, PrimaryKeyId orgUid, string Name, ArrayList VisibleGroups)
        {
            if (!Security.IsUserInGroup(InternalSecureGroups.Administrator))
            {
                throw new AccessDeniedException();
            }

            // VisibleGroups
            ArrayList NewGroups     = new ArrayList(VisibleGroups);
            ArrayList DeletedGroups = new ArrayList();

            using (IDataReader reader = DBGroup.GetListGroupsByPartner(PartnerId, false, true))
            {
                while (reader.Read())
                {
                    int GroupId = (int)reader["GroupId"];
                    if (NewGroups.Contains(GroupId))
                    {
                        NewGroups.Remove(GroupId);
                    }
                    else
                    {
                        DeletedGroups.Add(GroupId);
                    }
                }
            }

            using (DbTransaction tran = DbTransaction.Begin())
            {
                DBGroup.Update(PartnerId, Name);

                // Remove Groups
                foreach (int GroupId in DeletedGroups)
                {
                    DBGroup.DeletePartnerGroup(PartnerId, GroupId);
                }

                // Add Groups
                foreach (int GroupId in NewGroups)
                {
                    DBGroup.AddPartnerGroup(PartnerId, GroupId);
                }

                DBGroup.UpdateClient(PartnerId, contactUid, orgUid);

                tran.Commit();
            }
        }