public ActionResult bloglist() { p.onTable = "Fetch_Blog_Data"; ds = dl.FetchMaster(p); List <blogdata> bloglist = new List <blogdata>(); try { foreach (DataRow i in ds.Tables[0].Rows) { blogdata cs = new blogdata(); cs.blogid = i["blogid"].ToString(); cs.title = i["title"].ToString(); cs.image = i["image"].ToString(); cs.videourl = i["videourl"].ToString(); cs.discription = i["discription"].ToString(); cs.status = i["status"].ToString(); cs.blogdate = Convert.ToDateTime(i["blogdate"]).ToString("dd-MM-yyy"); bloglist.Add(cs); } ViewBag.bloglist = bloglist; } catch (Exception ex) { } return(View()); }
public ActionResult blog(blogdata bg, List <HttpPostedFileBase> f1) { string fileLocation = ""; string ItemUploadFolderPath = "~/DataFile/"; foreach (HttpPostedFileBase file in f1) { try { if (file.ContentLength == 0) { continue; } if (file.ContentLength > 0) { fileLocation = HelperFunctions.renameUploadFile(file, ItemUploadFolderPath); if (fileLocation == "") { fileLocation = ""; } } } catch (Exception ex) { } if (fileLocation == "" || fileLocation == null) { bg.image = bg.image; } else { bg.image = fileLocation; } } try { if (dl.Insertblog(bg) > 0) { TempData["Msg"] = "Blog Saved!"; } } catch (Exception ex) { return(Redirect("/admin/blog")); } return(Redirect("/admin/blog")); }