public ActionResult AddPackage(Package_Master pm, HttpPostedFileBase postedFile) { if (ModelState.IsValid) { string fileName = System.IO.Path.GetFileName(postedFile.FileName); //Set the Image File Path. string filePath = "~/Uploads/package_img/" + fileName; //Save the Image File in Folder. postedFile.SaveAs(Server.MapPath(filePath)); using (var context = new DestCoveryContext()) { context.Package_mst.Add(pm); context.SaveChanges(); } return(RedirectToAction("PackageDetails", "Admin", new { @packagename = pm.Package_Name })); } else { return(View()); } }
public ActionResult UpdatePackage(Package_Master pm, int packageid, string packagename) { if (Session["AdminID"] == null) { return(RedirectToAction("login", "Admin")); } else { ViewBag.PACKAGEID = packageid; ViewBag.PACKAGENAME = packagename; DestCoveryContext dcc = new DestCoveryContext(); var data = dcc.Package_mst.Find(pm.Package_Id); if (data != null) { data.Package_Tagline = pm.Package_Tagline; data.Package_Description = pm.Package_Description; data.Package_Price = pm.Package_Price; } dcc.SaveChanges(); return(RedirectToAction("PackageDetails", "Admin", new { @packageid = packageid, @packagename = packagename })); } }