public async Task <IActionResult> Post([FromForm] CommentViewModel model) { var comment = await MapViewModelToCommentInstance(model); var callerId = await _authHelper.GetCallerId(_caller); if (await _authHelper.CheckIfUserIsBanned(callerId)) { return(new BadRequestObjectResult( new { Message = "User currently bannend", StatusCodes.Status403Forbidden })); } comment = await _commentRepository.CreateAsync(comment); if (model.Files != null) { comment.Files = await _uploadHelper.UploadFiles(model.Files, comment.Id); comment = await _commentRepository.AddCommentFiles(comment); } return(new OkObjectResult(new { Message = "Whuhu", comment })); }
public async Task <IActionResult> Post([FromForm] PostViewModel model) { var post = MapViewModelToPostInstance(model); post.UserId = await _authHelper.GetCallerId(_caller); if (await _authHelper.CheckIfUserIsBanned(post.UserId)) { return(new BadRequestObjectResult( new { Message = "User currently bannend", StatusCodes.Status403Forbidden })); } post = await _postRepository.CreateAsync(post); // ReSharper disable once ComplexConditionExpression if (model.Files == null || !model.Files.Any()) { return(new OkObjectResult(new { Message = " bine ba ai postat o glumitza", post })); } post = await _postFilesUploadHelper.UploadFiles(model.Files, post); await _filesRepository.AddPostImagesAsync(post.Files); return(new OkObjectResult(new { Message = " ai fost ba in stare sa faci un post klumea bine ba usere ba", post })); }