public ActionResult Details(int id)
 {
     var downloads = new DownloadCollection();
     using (var database = new DatabaseEntities())
     {
         var item = database.ItemById(id);
         if (item == null)
             return HttpNotFound();
         downloads.PrimaryItem = new ItemViewModel(item);
         AddDependencies(downloads, item);
     }
     return Json(downloads, JsonRequestBehavior.AllowGet);
 }
 private void AddDependencies(DownloadCollection collection, Item item)
 {
     collection.Items.Add(new ItemViewModel(item));
     foreach (var blob in item.Blobs)
     {
         collection.Downloads.Add(new Download
         {
             DestinationPath = blob.DestinationPath,
             DownloadUrl = blob.DownloadUrl
         });
     }
     foreach (var dependency in item.Dependencies)
         AddDependencies(collection, dependency.Item);
 }