public int AddAlbum(string denumire) { if (CurrentUser.IsBanned) { return(-1); } Domain.Album album = new Domain.Album { Name = denumire, UserId = CurrentUser.Id }; unitOfWork.Albums.Add(album); unitOfWork.SaveChanges(); return(album.Id); }
public void UpdateAlbum(Album album) { Album oldAlbum = db.albums.Find(album.albumID); db.Entry(oldAlbum).CurrentValues.SetValues(album); db.SaveChanges(); }
public Album CreateAlbum(Album album) { db.albums.Add(album); db.SaveChanges(); return album; }
public ActionResult WijzigAlbum(Album album, HttpPostedFileBase file) { try { Album oldAlbum = albumManager.GetAlbum(album.albumID); byte[] imgByte; if (file != null && file.ContentLength > 0) { using (MemoryStream ms = new MemoryStream()) { file.InputStream.CopyTo(ms); imgByte = ms.GetBuffer(); Image a = byteArrayToImage(imgByte); a = Resize(a, 1920, 1080); imgByte = imageToByteArray(a); } album.afbeeldingAlbum = imgByte; } else { album.afbeeldingAlbum = oldAlbum.afbeeldingAlbum; } // TODO: Add update logic here album.datum = oldAlbum.datum; albumManager.ChangeAlbum(album); return RedirectToAction("Lijst"); } catch { return View(); } }
public ActionResult NieuwAlbum(Album album, HttpPostedFileBase file) { try { byte[] imgByte; if (file != null && file.ContentLength > 0) { using (MemoryStream ms = new MemoryStream()) { file.InputStream.CopyTo(ms); imgByte = ms.GetBuffer(); Image a = byteArrayToImage(imgByte); a = Resize(a, 250, 150); imgByte = imageToByteArray(a); } } else { Image image = Image.FromFile(Path.Combine(Server.MapPath("/Images/logo/"), "default.png")); using (MemoryStream ms = new MemoryStream()) { MemoryStream ms2 = new MemoryStream(); image.Save(ms2, System.Drawing.Imaging.ImageFormat.Png); imgByte = ms2.ToArray(); } } // TODO: Add insert logic here album.afbeeldingAlbum = imgByte; album.adminNaam = User.Identity.Name; album.datum = DateTime.Now; albumManager.CreateAlbum(album); return RedirectToAction("Lijst"); } catch { return View(); } }
public ActionResult NieuwAlbum() { Album album = new Album(); return View(album); }