コード例 #1
0
        public async Task <Unit> Handle(DeletePostCommand request, CancellationToken cancellationToken)
        {
            _deletePost = await GetPost(request.Id);

            await _postRepository.DeleteAsync(_deletePost);

            return(Unit.Value);
        }
コード例 #2
0
        public async Task <long> Handle(AddPostCommand request, CancellationToken cancellationToken)
        {
            _newPost = CreateNewPost(request);

            await _postRepository.AddAsync(_newPost);

            await _postRepository.SaveChangesAsync();

            return(_newPost.Id);
        }
コード例 #3
0
        public async Task <long> Handle(UpdatePostCommand request, CancellationToken cancellationToken)
        {
            _updatePost = await GetPost(request.Id);

            UpdatePost(request, _updatePost);

            await _postRepository.UpdateAsync(_updatePost);

            await _postRepository.SaveChangesAsync();

            return(_updatePost.Id);
        }
コード例 #4
0
 private void UpdatePost(UpdatePostCommand model, dbEntities.Post dbPost)
 {
     _mapper.Map(model, dbPost);
     dbPost.LastModifiedAt = DateTime.UtcNow;
 }
コード例 #5
0
 private void UpdatePost(UpdatePostCommand model, dbEntities.Post dbPost)
 {
     _mapper.Map(model, dbPost);
 }