Ejemplo n.º 1
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                var ct = this.ContentType;

                string ctName = txtCtName.Text;
                if (configProvider.GetContentTypes(ct.ListMetadataId).Any(cot => cot.Id != ct.Id && cot.Name.ToLower().Equals(ctName.ToLower())))
                {
                    throw new Exception("Content type with name '" + ctName + "' already exists!");
                }

                ct.Name          = ctName;
                ct.DispItemUrl   = txtDisplayFormUrl.Text;
                ct.EditItemUrl   = txtEditFormUrl.Text;
                ct.NewItemUrl    = txtNewFormUrl.Text;
                ct.IsOnNewAction = chIsVisibleOnNew.Checked;

                if (!ct.IsDefault)
                {
                    ct.IsDefault = chIsDefault.Checked; // user cannot remove 'IsDefault' flag
                }
                // custom actions
                var otherActions = ct.ListMetadataActions.Where(act => act.ContentTypeId != this.ContentTypeId);
                ct.ListMetadataActions.Clear();
                var ca = CustomActions;
                ca.ToList().ForEach(a => { a.ListMetadataId = ct.ListMetadataId; a.ContentTypeId = ct.Id; });
                ca.ToList().AddRange(otherActions);
                ct.ListMetadataActions = new Collection <ListMetadataAction>(ca.ToList());

                // update data in DB
                configProvider.SaveContentType(ct);

                // REMOVE IsDefault flag from other views
                if (chIsDefault.Visible && chIsDefault.Checked)
                {
                    // chIsDefault.Visible == true   means that on PageLoad view was NOT Default
                    this.RemoveDefaultFlagsFromOtherCTs(ct.Id);
                }

                // close form
                Utils.GoBackOnSuccess(this, Context);
            }
            catch (Exception ex)
            {
                panelError.Controls.Add(new Label {
                    Text = ex.Message, ForeColor = Color.Red
                });
            }
        }
Ejemplo n.º 2
0
        public listView <Entity> ContentTypeList(string version, ICollection <abstractSearch> filter, QueryDisplayParams query)
        {
            DisableCaching();
            var result = new listView <Entity>();

            try
            {
                var listId = filter.filterTextValue("listId").ToGuid();
                result.page = new pager <Entity>();
                var service = new RosterConfigService();
                var content = service.GetContentTypes(listId);
                result.total = content.Count();
                content.Take(query.currentPageSize).Skip(query.currentPageNum * query.currentPageSize).ToList().ForEach(item =>
                {
                    result.page.pageItems.Add(new Entity
                    {
                        Key    = item.Id.ToSafeString(),
                        Name   = item.Name,
                        Fields = item.ToNamed()
                    });
                });
            }
            catch (Exception ex)
            {
                result.message.message      = ex.Message;
                result.message.messageLevel = messageLevelEnum.critical;
                //HandleException(ex);
            }
            return(result);
        }