public IActionResult AddPhoto(PhotoModel model, int?albumId) { if (ModelState.IsValid) { var photo = new Domain.Photo() { AlbumId = albumId, PostId = null, MIMEType = model.Binar.ContentType }; using (var memoryStream = new MemoryStream()) { model.Binar.CopyTo(memoryStream); photo.Binary = memoryStream.ToArray(); } photoService.AddPhoto(photo); return(RedirectToAction("Album", "Profile", new { albumId = model.AlbumId })); } if (albumId == null) { return(NotFound()); } AlbumViewerModel albumViewerModel = new AlbumViewerModel() { PhotoModel = model, HasThisAlbum = albumService.HasThisAlbum(albumId.Value), Id = albumId.Value, Name = albumService.GetAlbum(albumId.Value).Name }; return(View("Album", albumViewerModel)); }
public IActionResult Album(int?albumId) { if (albumId == null) { return(NotFound()); } if (!albumService.CanSeeAlbum(albumId.Value)) { return(ForbidView()); } var album = albumService.GetAlbum(albumId.Value); if (album == null) { return(NotFound()); } AlbumViewerModel albumViewerModel = new AlbumViewerModel() { PhotoModel = new PhotoModel() { AlbumId = albumId }, HasThisAlbum = albumService.HasThisAlbum(albumId.Value), Id = albumId.Value, Name = album.Name }; return(View(albumViewerModel)); }
public IActionResult AlbumChangeName(AlbumViewerModel model) { if (string.IsNullOrWhiteSpace(model.Name)) { return(View("Album", model)); } albumService.ChangeName(model.Id, model.Name); return(RedirectToAction("Album", "Profile", new { albumId = model.Id })); }
public IActionResult Album(int?albumId) { if (albumId == null) { return(NotFound()); } var album = albumService.GetAlbum(albumId.Value); if (album == null) { return(NotFound()); } AlbumViewerModel model = new AlbumViewerModel() { Id = albumId.Value, Name = album.Name }; return(View(model)); }