public ActionResult addnewrecord(tblProduct item) //public ActionResult addnewrecord(tbl_data d, HttpPostedFileBase imgfile) { if (ModelState.IsValid) { tbl_data tbl = new tbl_data() { P_name = item.ProductName, P_DES = item.Price.ToString(), img = ConvertToByte(item.ImageUpload) }; db.tbl_data.Add(tbl); db.SaveChanges(); } //tbl_data di = new tbl_data(); //string path = uploadimage(imgfile); //if (path.Equals("-1")) //{ //} //else //{ // di.P_name = d.P_name; // di.P_DES = d.P_DES; // di.P_IMAGE = d.P_IMAGE; // db.tbl_data.Add(di); // db.SaveChanges(); // ViewBag.Message = "Data added...."; //} return(View()); }
public ActionResult addnewrecord(tbl_data d, HttpPostedFileBase imgfile) { tbl_data di = new tbl_data(); string path = uploadimage(imgfile); if (path.Equals("-1")) { } else { di.P_name = d.P_name; di.P_DES = d.P_DES; di.P_IMAGE = d.P_IMAGE; db.tbl_data.Add(di); db.SaveChanges(); ViewBag.Message = "Data added...."; } return(View()); }