示例#1
0
        public async Task <IActionResult> GetPostEditViewModelAsync(int id)
        {
            var post = await _postService.GetAsync(id);

            if (!HasCurrentUserEditRights(post))
            {
                return(StatusCode(403));
            }

            if (post.IsDeleted || post == null)
            {
                return(StatusCode(404));
            }
            var files = await _fileService.GetFilesForPost(post.Id);

            var postEditViewModel = PostMapper.ConvertToPostEditModel(post);

            postEditViewModel.Files = files.Select(FileMapper.ConvertToFileInfoViewModel).ToList();
            return(Ok(postEditViewModel));
        }