예제 #1
0
 public virtual ActionResult DeleteFile(long id)
 {
     try
     {
         using (var scope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled))
         {
             var mypatfile = new AddressUrlFile(Path.Combine("~\\"));
             var attach    = _attachmentService.Find(id);
             if (attach == null)
             {
                 return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
             }
             string fullPath = Request.MapPath(mypatfile.UploadFiles + attach.File + attach.Extention);
             if (System.IO.File.Exists(fullPath))
             {
                 System.IO.File.Delete(fullPath);
             }
             _attachmentService.Delete(id);
             scope.Complete();
             return(Json(new { isError = false, Message = "حذف انجام شد" }));
         }
     }
     catch (Exception exception)
     {
         Elmah.ErrorSignal.FromCurrentContext().Raise(exception);
         return(Json(new { isError = true, Message = "خطا در حذف پیوست" }));
     }
 }
 public virtual ActionResult DeleteFile(long id)
 {
     try
     {
         var mypatfile = new AddressUrlFile(Path.Combine("~\\"));
         var attach    = _attachmentService.Find(id);
         if (attach == null)
         {
             return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
         }
         string fullPath = Request.MapPath(mypatfile.UploadFiles + attach.File + attach.Extention);
         if (System.IO.File.Exists(fullPath))
         {
             System.IO.File.Delete(fullPath);
         }
         _attachmentService.Delete(id);
         return(Json(new { isError = false, Message = "حذف انجام شد" }));
     }
     catch (Exception)
     {
         return(Json(new { isError = true, Message = "خطا در حذف پیوست" }));
     }
 }