public async Task <IActionResult> OnPost() { string ext = Path.GetExtension(Image.FileName); string imgName = $"{DateTime.Now.Ticks}{Name}{ext}"; if (Image != null) { var url = await _image.Upload(Image, imgName); await _post.Create(Post, url); } return(RedirectToPage("Posts")); }
public async Task <IActionResult> CreatePost(CreatePostModel model) //Add post , submit post //ПРОВЕРИ ТУК { var userId = _userManager.GetUserId(User); //build in userManager service var user = _userManager.FindByIdAsync(userId).Result; var newPost = GeneratePost(model, user); _postService.Create(newPost).Wait(); //с Асинк не работи, за това добавих Wait,блок the thread until the task is complete return(RedirectToAction("Index", "Post", new { id = newPost.Id })); //TODO: Rating }
public IActionResult Create([FromBody] CreatePostViewModel postToCreate) { var post = new Post(); var identity = (ClaimsIdentity)User.Identity; IEnumerable <Claim> claims = identity.Claims; post.Content = postToCreate.Content; post.Title = postToCreate.Title; post.Forum.Id = postToCreate.ForumId; post.User.Id = int.Parse(claims.ElementAt(2).Value); _post.Create(post); return(View()); }
public void Post(Dto.Post post) { _postBus.Create(post); }
public void Create(Post post) { _context.Create(post); }