public ActionResult projectData(int pid)
        {
            HttpPostedFileBase file = Request.Files["img"];

            if (file != null)
            {
                DatabaseEntities db  = new DatabaseEntities();
                projectData      obj = new projectData();
                obj.projectID = pid;
                obj.date      = System.DateTime.Now;
                string fileName = Path.GetFileName(file.FileName).ToString();
                obj.link = fileName;
                db.projectDatas.Add(obj);

                var path = Path.Combine(Server.MapPath("~/Content/projectsData"), fileName);
                file.SaveAs(path);
                db.SaveChanges();
                ViewBag.AlertMessage = "SuccessfullyUploaded";
            }
            else
            {
                ViewBag.AlertMessage = "files can not be uploaded";
            }
            return(RedirectToAction("projectProgress", "Home", new { id = pid }));
        }
 public string deleteImage(int sNo)
 {
     try
     {
         DatabaseEntities db   = new DatabaseEntities();
         projectData      data = db.projectDatas.Find(sNo);
         var path = Path.Combine(Server.MapPath("~/Content/projectsData"), data.link);
         System.IO.File.Delete(path);
         db.projectDatas.Remove(data);
         int i = db.SaveChanges();
         if (i > 0)
         {
             return("ok");
         }
         else
         {
             return("not");
         }
     }
     catch (Exception e)
     {
         return(e.Message);
     }
 }
예제 #3
0
 public JsonResult project(string MyChecked)
 {
     project pj = new project();
     projectData pjd = new projectData();
     var array = MyChecked.Split(',');
     if (MyChecked != "" && MyChecked != null)
     {
         for (var i = 0; i < array.Length; i++)
         {
             //var Original = dred.Get().ToList().Where(a => a.num.ToString() == array[i]).SingleOrDefault();
             ////var DelPath = System.IO.Path.Combine(Server.MapPath("~/upload/dressdesign/"), Original.img);
             ////System.IO.File.Delete(DelPath);
             //if (Original.jsonimg != "no_img.jpg")
             //{
             //    var jsonstr = JsonConvert.DeserializeObject<List<jsonSer>>(Original.jsonimg);
             //    var DelJsonPath = Server.MapPath("~/upload/dressdesign/");
             //    foreach (var j in jsonstr)
             //    {
             //        var DelJsonPathing = System.IO.Path.Combine(DelJsonPath, j.content);
             //        System.IO.File.Delete(DelJsonPathing);
             //    }
             //}
             pj.num = Convert.ToInt32(array[i]);
             pjd.Delete(pj);
         }
     }
     return Json("");
 }