Esempio n. 1
0
 public HttpResponseMessage DeleteUnusedResources([FromBody] List <ResourceModel> list)
 {
     using (var db = new OnlineMusicEntities())
     {
         foreach (ResourceModel model in list)
         {
             try
             {
                 var resource = (from r in db.Resources where r.Id == model.Id select r).FirstOrDefault();
                 if (resource != null)
                 {
                     if (services.DeleteFile(resource.Id))
                     {
                         db.Resources.Remove(resource);
                     }
                 }
             }
             catch { }
         }
         db.SaveChanges();
         return(Request.CreateResponse(HttpStatusCode.OK));
     }
 }
 public ActionResult DeleteFile(GoogleDriveFile file)
 {
     GoogleDriveServices.DeleteFile(file, Server.MapPath("~/drive-client.json"));
     return(RedirectToAction("GetGoogleDriveFiles"));
 }