public ActionResult Create(HttpPostedFileBase page_img1, HttpPostedFileBase page_img2,HttpPostedFileBase page_img3 ,tbl_pagedetails _page) { tbl_pagedetails _tbl_page = new tbl_pagedetails(); if (page_img1 != null) { pic = Path.GetFileName(page_img1.FileName); string path = System.IO.Path.Combine(Server.MapPath("~/images1/"), pic); page_img1.SaveAs(path); } if (page_img2 != null) { pic1 = Path.GetFileName(page_img2.FileName); string path1 = System.IO.Path.Combine(Server.MapPath("~/images1/"), pic1); page_img2.SaveAs(path1); } if (page_img3 != null) { pic2 = Path.GetFileName(page_img3.FileName); string path2 = System.IO.Path.Combine(Server.MapPath("~/images1/"), pic2); page_img3.SaveAs(path2); } _tbl_page.page_content1 = Server.HtmlDecode(_page.page_content1); _tbl_page.page_content2 = Server.HtmlDecode(_page.page_content2); _tbl_page.page_content3 = Server.HtmlDecode(_page.page_content3); _tbl_page.page_img1 = pic; _tbl_page.page_img2 = pic1; _tbl_page.page_img3 = pic2; _tbl_page.page_header = _page.page_header; _tbl_page.menuid = _page.menuid; _tbl_page.BlogId = _page.BlogId; db.tbl_pagedetails.Add(_tbl_page); db.SaveChanges(); return RedirectToAction("Index"); }
public ActionResult Edit(HttpPostedFileBase page_img1, HttpPostedFileBase page_img2,HttpPostedFileBase page_img3 ,tbl_pagedetails _page, int? id) { try { tbl_pagedetails _tbl_page = db.tbl_pagedetails.Where(x => x.page_data_id == id).FirstOrDefault(); if (page_img1 != null) { pic = Path.GetFileName(page_img1.FileName); string path = System.IO.Path.Combine(Server.MapPath("~/images1/"), pic); page_img1.SaveAs(path); } else { } if (page_img2 != null) { pic1 = Path.GetFileName(page_img2.FileName); string path1 = System.IO.Path.Combine(Server.MapPath("~/images1/"), pic1); page_img2.SaveAs(path1); } else { } if (page_img3 != null) { pic2 = Path.GetFileName(page_img3.FileName); string path2 = System.IO.Path.Combine(Server.MapPath("~/images1/"), pic2); page_img3.SaveAs(path2); } else { } _tbl_page.page_content1 = Server.HtmlDecode(_page.page_content1); _tbl_page.page_content2 = Server.HtmlDecode(_page.page_content2); _tbl_page.page_content3 = Server.HtmlDecode(_page.page_content3); _tbl_page.page_img1 = pic; _tbl_page.page_img2 = pic1; _tbl_page.page_img3 = pic2; _tbl_page.page_header = _page.page_header; _tbl_page.menuid = _page.menuid; _tbl_page.BlogId = _page.BlogId; db.SaveChanges(); return RedirectToAction("Index"); } catch { return View(); } }