public IActionResult Publish() { var model = new PublishPostModel() { Picture = Picture.EmptyPicture }; return(View(model)); }
public async Task <IActionResult> Publish(PublishPostModel newPost, IFormFile pictureFile) { if (ModelState.IsValid) { var command = new PublishPostCommand(User.GetIdentifier(), newPost.Text, await pictureFile.ToByteArrayAsync()); var commandResult = await _dispatcher.Send(command); if (commandResult.IsSuccess) { return(RedirectToAction("Index", "Home")); } ModelState.AddModelError("", commandResult.Error); } else { ModelState.AddModelError("Picture", "Please select a picture to share together with your post."); } return(View(newPost)); }