Exemple #1
0
 public ActionResult Upload(HttpPostedFileBase uploaded,string AlbumName, string Title, string spetification)
 {
     var user = AuthHelper.GetUser(HttpContext);
     if (uploaded != null)
     {
         Photo image = new Photo()
         {
             IDPhoto = Guid.NewGuid(),
             Name = Title,
             Spetification = spetification,
             CountLikes = 0,//не пишет в дб
             Image = new byte[uploaded.ContentLength],
             ImageType = uploaded.ContentType
         };
         if (AlbumName != null)
         {
             image.IDAlbum = Binder.GetIdAlbum(user.idUser, AlbumName);//берет имменно такой альбом
         }
         else
         {
             image.IDAlbum = Binder.GetIdAlbum(user.idUser, "Other");
         }
         using (BinaryReader br = new BinaryReader(uploaded.InputStream))
         {
             image.Image = br.ReadBytes(image.Image.Length);
         }
         Binder.Add(image);
         //return File(image.Image, uploaded.ContentType);
     }
     return RedirectToAction("Profile", "User", user);
 }
Exemple #2
0
 public static bool Add(Photo image)
 {
     return bll.AddPhoto(image);
 }