protected override bool Update() { LayoutInfo layoutInfo = _layoutProvider.Select(ValidationHelper.GetInteger(Id, -1), ErrorList); if (layoutInfo != null) { layoutInfo.LayoutCategoryId = ValidationHelper.GetInteger(drlCategory.SelectedValue, 0); layoutInfo.Name = txtName.Text; layoutInfo.Description = txtDescription.Text; layoutInfo.Layout = txtBodyContent.Text; layoutInfo.IsMaster = false; layoutInfo.IsDeleted = false; if (flpScreenshot.HasFile) { string guid = Guid.NewGuid().ToString(); string fileName = guid + "_" + flpScreenshot.FileName; flpScreenshot.SaveAs(Server.MapPath("~/userfiles/pagelayouts/") + fileName); layoutInfo.Screenshot = fileName; } if (_layoutProvider.Update(layoutInfo, ErrorList)) { List<string> webPartZones = GetWebPartZones(layoutInfo.Layout); if (_layoutWebPartZoneProvider.DeleteByLayoutId(layoutInfo.Id, ErrorList)) { foreach (string item in webPartZones) { LayoutWebPartZoneInfo info = new LayoutWebPartZoneInfo(); info.Name = item; info.LayoutId = layoutInfo.Id; _layoutWebPartZoneProvider.Create(info, ErrorList); } } } } RedrictUrl = "/administrator/pagelayout/layouts.aspx?categoryid=" + drlCategory.SelectedValue; CancelUrl = RedrictUrl; return CheckErrors(); }
protected override bool Insert() { LayoutInfo layoutInfo = new LayoutInfo(); layoutInfo.Name = txtName.Text; layoutInfo.LayoutCategoryId = ValidationHelper.GetInteger(drlCategory.SelectedValue, 0); layoutInfo.Description = txtDescription.Text; layoutInfo.Layout = txtBodyContent.Text; layoutInfo.IsMaster = false; layoutInfo.IsDeleted = false; layoutInfo.BodyOption = string.Empty; layoutInfo.DocOption = string.Empty; layoutInfo.Css = string.Empty; if (flpScreenshot.HasFile) { string guid = Guid.NewGuid().ToString(); string fileName = guid + "_" + flpScreenshot.FileName; flpScreenshot.SaveAs(Server.MapPath("~/userfiles/pagelayouts/") + fileName); layoutInfo.Screenshot = fileName; } else layoutInfo.Screenshot = string.Empty; Object idObject = _layoutProvider.Create(layoutInfo, ErrorList); if (idObject != null) { List<string> webPartZones = GetWebPartZones(layoutInfo.Layout); foreach (string item in webPartZones) { LayoutWebPartZoneInfo info = new LayoutWebPartZoneInfo(); info.Name = item; info.LayoutId = ValidationHelper.GetInteger(idObject, 0); _layoutWebPartZoneProvider.Create(info, ErrorList); } } RedrictUrl = "/administrator/pagelayout/layouts.aspx?categoryid=" + drlCategory.SelectedValue; return CheckErrors(); }