Exemple #1
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");
 }
Exemple #2
0
 public void AddImage(Zdjecie img)
 {
     _db.Zdjecia.Add(img);
 }