public ActionResult UpdateAlbum(UpdateAlbumViewModel model, HttpPostedFileBase image = null) { if (ModelState.IsValid) { string userId = User.Identity.GetUserId(); _logger.Info("User {0} requested to update album {1}", userId, model.AlbumId); ActionResult alternativeResult = ErrorIfNotAnOwner(model.UniqueUserName, Errors.AttemptToRemoveAlbum, _userService, userId, _logger); if (alternativeResult == null) { if (image != null) { model.ImageMimeType = image.ContentType; model.ImageData = new byte[image.ContentLength]; image.InputStream.Read(model.ImageData, 0, image.ContentLength); } UpdateAlbum request = MapperHelper.GetValue <UpdateAlbumViewModel, UpdateAlbum>(model); _albumService.UpdateAlbum(request); _logger.Info("Album {0} successfully updated", model.AlbumId); TempData["ResultMessage"] = string.Format(SuccessMessages.SuccessfullyUpdatedAlbum, model.AlbumName); return(RedirectToAction("ViewAlbum", new { albumName = model.AlbumName, uniqueUserName = model.UniqueUserName })); } return(alternativeResult); } return(View(model)); }
public ActionResult UpdateAlbum(string albumName, string uniqueUserName) { ActionResult alternativeResult = ErrorIfNotAnOwner(uniqueUserName, Errors.AttemptToUpdateAlbum, _userService, _logger); if (alternativeResult == null) { var request = new RequestEntity { AlbumName = albumName, UniqueUserName = uniqueUserName }; var response = _albumService.GetAlbumForUpdate(request); UpdateAlbumViewModel result = MapperHelper.GetValue <UpdateAlbum, UpdateAlbumViewModel>(response); return(View(result)); } return(alternativeResult); }