public JsonResult GetRemoveDomainDialog(int[] RmoveDomains)
        {
            DomainListModel _model = new DomainListModel();

            foreach (int DomainID in RmoveDomains)
            {
                Domain domain = Web.Admin.Logic.Collections.Domains.GetBy(DomainID);
                _model.Domains.Add(domain);
            }

            return(Json(new
            {
                Html = this.RenderPartialView(@"_RemoveDomains", _model),
            }, JsonRequestBehavior.AllowGet));
        }
        public JsonResult RemoveDomain(int[] RemoveDomains)
        {
            DomainListModel _model   = new DomainListModel();
            List <Domain>   _deleted = new List <Domain>();

            foreach (int DomainID in RemoveDomains)
            {
                Domain domain = Web.Admin.Logic.Collections.Domains.GetBy(DomainID);
                List <ProfileField> _profileFields = ProfileFields.GetByDomain(DomainID);

                if (ProfileFields.GetByDomain(domain.DomainID).Count > 0)
                {
                    domain.WasDeleted = false;
                    domain.UIMessage  = "The domain has not been deleted. Attached fields: ";
                    foreach (ProfileField profileField in _profileFields)
                    {
                        domain.UIMessage += "<u>" + profileField.FieldName + "</u>&nbsp;";
                    }
                    domain.UIMessageType = UIMessageType.Warning;
                    AuditEvent.AppEventSuccess(Profile.Member.Email, String.Format(AuditEvent.RoleContainsMembers, domain.Name));
                }
                else
                {
                    if (domain.Delete())
                    {
                        domain.WasDeleted    = true;
                        domain.UIMessage     = "The domain has been deleted.";
                        domain.UIMessageType = UIMessageType.Success;
                        AuditEvent.AppEventSuccess(Profile.Member.Email, String.Format(AuditEvent.RoleDeleted, domain.Name));
                    }
                }

                _deleted.Add(domain);
            }

            _model.Domains = _deleted;

            return(Json(new
            {
                NotifyType = NotifyType.Dialog,
                Html = this.RenderPartialView(@"_RemoveDomainsResult", _model)
            }, JsonRequestBehavior.AllowGet));
        }
コード例 #3
0
ファイル: DomainsView.cs プロジェクト: dianatatu/REACH
        /*
         * Handlers for external events
         */
        #region external_events

        private void OnDomainsReceived(DomainListModel model)
        {
            if (!domainsRequested)
            {
                return;
            }

            while (!this.IsHandleCreated)
            {
                ;
            }
            if (this.InvokeRequired)
            {
                this.Invoke((DomainsController.ExternalEventHandler)
                            OnDomainsReceived, model);
                return;
            }

            domainsRequested    = false;
            domainList.Location = new Point(429, 67);
            System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(DomainsView));

            List <DomainData> domains = model.AllDomains;

            domainList.Size = new Size(136, 2 + (22 - 1) * domains.Count);
            for (int i = 0; i < domains.Count; ++i)
            {
                // main container for domain
                Panel container = new Panel();
                container.Location    = new Point(-1, -1 + 21 * i);
                container.Size        = new Size(136, 22);
                container.BorderStyle = BorderStyle.FixedSingle;
                container.Visible     = true;
                domainList.Controls.Add(container);

                // cover
                TransparentPanel cover = new TransparentPanel();
                cover.Location    = new Point(0, 0);
                cover.Size        = container.Size;
                cover.MouseEnter += new EventHandler(cover_MouseEnter);
                cover.MouseLeave += new EventHandler(cover_MouseLeave);
                cover.Click      += new EventHandler(cover_Click);
                container.Controls.Add(cover);

                // image box
                PictureBox img = new PictureBox();
                img.Image    = ((Image)(resources.GetObject("news.Image")));
                img.Location = new Point(2, 1);
                img.Margin   = new System.Windows.Forms.Padding(2);
                img.Size     = new Size(18, 20);
                img.SizeMode = PictureBoxSizeMode.StretchImage;
                img.TabIndex = 7;
                img.TabStop  = false;
                container.Controls.Add(img);

                // domain title
                Label title = new Label();
                title.AutoSize = true;
                title.Font     = new Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
                title.Location = new Point(24, 2);
                title.Margin   = new Padding(2, 0, 2, 0);
                title.Size     = new Size(74, 17);
                title.TabIndex = 6;
                title.Text     = domains[i].Name;
                container.Controls.Add(title);
            }

            changeState();
        }