public async Task <IActionResult> Add([FromForm] CreatePostDto createPostDto) { try { string createdFilePath = _fileService.CreateLocalFile(createPostDto.PhotoFile, PostPhotosFolder); var user = await _userManager.GetUserAsync(User); if (user == null) { return(BadRequest()); } createPostDto.AuthorId = user.Id; CreatePostViewModel createPostViewModel = CustomMapper.GetCreatePostViewModel(createPostDto, createdFilePath); var result = await _postService.Add(createPostViewModel); if (result.IsValid) { return(Ok()); } return(BadRequest(result.Errors)); } catch (IOException) { } return(BadRequest()); }