Exemple #1
0
 public bool DeleteImages(string blobName)
 {
     if (blobName == null)
     {
         return false;
     }
     try
     {
         ImageUpload imageUpload = new ImageUpload();
         imageUpload.DeleteImageByNameWithMiniatures(blobName);
         try
         {
             _zdjecieRepo.DeleteImageByBlobName(blobName);
             _zdjecieRepo.SaveChanges();
             return true;
         }
         catch
         {
             return false;
         }
     }
     catch
     {
         return false;
     }
 }
Exemple #2
0
 public ActionResult UploadImage(HttpPostedFileBase fileBase)
 {
     if (fileBase != null && fileBase.ContentLength > 0)
     {
         try
         {
             ImageUpload imageUpload = new ImageUpload();
             string nameWithExtension = imageUpload.UploadImageAndReturnImageName(fileBase);
             if (nameWithExtension == null)
                 return RedirectToAction("Lista", "Galeria");
             try
             {
                 Zdjecie img = new Zdjecie()
                 {
                     UzytkownikId = User.Identity.GetUserId(),
                     Name = nameWithExtension
                 };
                 _zdjecieRepo.AddImage(img);
                 _zdjecieRepo.SaveChanges();
             }
             catch
             {
                 imageUpload.DeleteImageByNameWithMiniatures(nameWithExtension);
             }
         }
         catch { }
     }
     return RedirectToAction("Lista", "Galeria");
 }