public async Task <IActionResult> SetPost(Post post, User user, IFormFile image) { user.Id = (int)HttpContext.Session.GetInt32("Id"); post.Posted = DateTime.Now; if (image != null && image.Length > 0) { if (image.ContentType == "image/png" || image.ContentType == "image/jpeg") { using (var stream = new MemoryStream()) { await image.CopyToAsync(stream); post.Image = stream.ToArray(); } _postLogic.SetPost(post, user); return(RedirectToAction("Overview", "Profile")); } } return(RedirectToAction("Post", "Profile")); }