public ActionResult ImagesliderInsert(Imageslider img, HttpPostedFileBase file) { //Will check all the data regarding their validation , and if they were valid ,they are inserted into database and then redirecting to the index view . /*this is for image upload*/ if (ModelState.IsValid) { if (file != null) { file.SaveAs(HttpContext.Server.MapPath("~/Content/images/imageslider/") + file.FileName); img.Image = file.FileName; } objImg.commitInsert(img); return(RedirectToAction("ImagesliderIndex")); } if (ModelState.IsValid) { try { objImg.commitInsert(img); return(RedirectToAction("ImagesliderIndex")); } catch { return(View(img)); } } return(View(img)); }
//insert public bool commitInsert(Imageslider img) { using (objImg) { objImg.Imagesliders.InsertOnSubmit(img); //commit insert with db objImg.SubmitChanges(); return(true); } }
public ActionResult ImagesliderDelete(int ImageId, Imageslider img) { //Selected image will be deleted from the database try { objImg.commitDelete(ImageId); return(RedirectToAction("ImagesliderIndex")); } catch { return(View()); } }
partial void DeleteImageslider(Imageslider instance);
partial void UpdateImageslider(Imageslider instance);
partial void InsertImageslider(Imageslider instance);