public ActionResult GallaryPhotos(PhotoUploadGallary add, HttpPostedFileBase File) { Gallary.Upload_Photo_Gallary(add, File); //Message TempData["msg"] = "<script>alert('Upload Photos Successfully');</script>"; //Current Url Redirect return(Redirect(HttpContext.Request.UrlReferrer.AbsoluteUri)); // return View(); }
//Add Photo public bool Upload_Photo_Gallary(PhotoUploadGallary upload, HttpPostedFileBase File) { string filename = Path.GetFileNameWithoutExtension(File.FileName); string extension = Path.GetExtension(File.FileName); filename = filename + DateTime.Now.ToString("yymmssfff") + extension; upload.ImagePath = "~/Content/Image/GallaryPhoto/" + filename; filename = Path.Combine(System.Web.HttpContext.Current.Server.MapPath("~/Content/Image/GallaryPhoto/"), filename); upload.Shared = "public"; File.SaveAs(filename); Db.Set <PhotoUploadGallary>().Add(upload); Db.SaveChanges(); return(true); }
//Update Gallary Photo public bool UpdateGallaryPhoto(PhotoUploadGallary UpdatePhoto) { Db.Entry(UpdatePhoto).State = EntityState.Modified; Db.SaveChanges(); return(true); }