public virtual void AddColumnWidth(PageLayoutColumnWidthValue item)
 {
     columnWidths.Add(item);
 }
        public virtual ActionResult UpdateLayoutSettingsForm(LayoutSettingsModel layoutSettings)
        {
            bool isSuccessed = true;
            if (ModelState.IsValid)
            {
                var pageLayoutService = ServiceLocator.Current.GetInstance<IPageLayoutService>();
                var pageLayoutRowService = ServiceLocator.Current.GetInstance<IPageLayoutRowService>();
                var columnWidthValueService = ServiceLocator.Current.GetInstance<IPageLayoutColumnWidthValueService>();
                PageLayout pageLayout = pageLayoutService.Find(layoutSettings.LayoutId);

                //check page permissions
                if (pageLayout == null || !permissionService.IsAllowed((Int32)PageOperations.Update, this.CorePrincipal(), typeof(Page), pageLayout.Page.Id, IsPageOwner(pageLayout.Page), PermissionOperationLevel.Object))
                {
                    throw new HttpException((int)HttpStatusCode.NotFound, Translate("Messages.NotFound"));
                }

                foreach (RowSettings rowSettings in layoutSettings.RowsSetting)
                {
                    PageLayoutRow row = pageLayoutRowService.Find(rowSettings.RowId);
                    if (row == null)
                    {
                        throw new HttpException((int)HttpStatusCode.NotFound, Translate("Messages.NotFound"));
                    }
                    if (row.Columns.Count() != rowSettings.ColumnsWidth.Count)
                    {
                        throw new HttpException((int)HttpStatusCode.BadRequest, Translate("Messages.BadRequest"));
                    }
                    int columnIndex = 0;
                    foreach (PageLayoutColumn column in row.Columns)
                    {
                        PageLayoutColumnWidthValue columnWidthValue = pageLayout.ColumnWidths.FirstOrDefault(columnWidths => columnWidths.Column == column);
                        if (columnWidthValue == null)
                        {
                            columnWidthValue = new PageLayoutColumnWidthValue
                            {
                                Column = column,
                                PageLayout = pageLayout,

                            };
                        }
                        columnWidthValue.WidthValue = rowSettings.ColumnsWidth[columnIndex++];
                        isSuccessed = isSuccessed && columnWidthValueService.Save(columnWidthValue);
                    }
                }
            }
            return Json(new { IsSuccessed = isSuccessed });
        }
Exemple #3
0
 public virtual void AddColumnWidth(PageLayoutColumnWidthValue item)
 {
     columnWidths.Add(item);
 }