private void SavePage(HttpContext context) { HttpCookie cookie = req.Cookies["client"]; if (cookie != null) { int clientID = int.Parse(cookie.Value); string ID = p["ID"]; Data.POCOS.Page page; if (!string.IsNullOrEmpty(ID) && ID != "0") { page = Data.POCOS.Page.Single(int.Parse(ID)); } else { page = new Data.POCOS.Page(); } page.FooterText = p["FooterText"]; page.HeaderText = p["HeaderText"]; page.Location = p["Location"]; page.MainSite = p["MainSite"]; page.Text = p["Text"]; page.Def = !string.IsNullOrEmpty(p["Def"]); page.Locked = !string.IsNullOrEmpty(p["Locked"]); page.ClientID = clientID; if (req.Files.Count > 0) { HttpPostedFile file = req.Files["HeaderImage"]; if (file.ContentLength > 0) { string filename = file.FileName; string filepath = Common.ImagesPath + filename; file.SaveAs(filepath); page.HeaderImage = filename; } file = req.Files["FooterImage"]; if (file.ContentLength > 0) { string filename = file.FileName; string filepath = Common.ImagesPath + filename; file.SaveAs(filepath); page.FooterImage = filename; } file = req.Files["PageImage"]; if (file.ContentLength > 0) { string filename = file.FileName; string filepath = Common.ImagesPath + filename; file.SaveAs(filepath); page.PageImage = filename; } } page.Save(); } res.WriteJsonSuccess(); }
private void SavePage(HttpContext context) { HttpCookie cookie = req.Cookies["client"]; if (cookie != null) { int clientID = int.Parse(cookie.Value); string ID = p["ID"]; Data.POCOS.Page page; if (!string.IsNullOrEmpty(ID) && ID != "0") page = Data.POCOS.Page.Single(int.Parse(ID)); else page = new Data.POCOS.Page(); page.FooterText = p["FooterText"]; page.HeaderText = p["HeaderText"]; page.Location = p["Location"]; page.MainSite = p["MainSite"]; page.Text = p["Text"]; page.Def = !string.IsNullOrEmpty(p["Def"]); page.Locked = !string.IsNullOrEmpty(p["Locked"]); page.ClientID = clientID; if (req.Files.Count > 0) { HttpPostedFile file = req.Files["HeaderImage"]; if (file.ContentLength > 0) { string filename = file.FileName; string filepath = Common.ImagesPath + filename; file.SaveAs(filepath); page.HeaderImage = filename; } file = req.Files["FooterImage"]; if (file.ContentLength > 0) { string filename = file.FileName; string filepath = Common.ImagesPath + filename; file.SaveAs(filepath); page.FooterImage = filename; } file = req.Files["PageImage"]; if (file.ContentLength > 0) { string filename = file.FileName; string filepath = Common.ImagesPath + filename; file.SaveAs(filepath); page.PageImage = filename; } } page.Save(); } res.WriteJsonSuccess(); }