public string UploadUpdatedFiles() { string sPath = ""; sPath = System.Web.Hosting.HostingEnvironment.MapPath("~/Images/"); var request = System.Web.HttpContext.Current.Request; System.Web.HttpFileCollection hfc = System.Web.HttpContext.Current.Request.Files; //var remark = request["remark"].ToString(); if (hfc != null) { for (int iCnt = 0; iCnt <= hfc.Count - 1; iCnt++) { System.Web.HttpPostedFile hpf = hfc[iCnt]; if (hpf.ContentLength > 0) { string FileName = (Path.GetFileName(hpf.FileName)); //if (!File.Exists(sPath + FileName)) //{ // SAVE THE FILES IN THE FOLDER. hpf.SaveAs(sPath + FileName); PROPERTYPHOTO obj = new PROPERTYPHOTO(); obj.PHOTO = FileName; obj.PROPERTYID = Convert.ToInt32(request["PropertyID"]); img.PROPERTYPHOTOes.Add(obj); img.SaveChanges(); //} } } } return("Upload Failed"); }
public dynamic DeletePhoto(int ID) { try { PROPERTYPHOTO foto = new PROPERTYPHOTO(); foto = db.PROPERTYPHOTOes.Where(rr => rr.PROPERTY_PHOTO_ID == ID).FirstOrDefault(); db.PROPERTYPHOTOes.Remove(foto); db.SaveChanges(); } catch (Exception) { return("not finished"); } return("finished"); }