public async Task <Unit> Handle(DeletePostCommand request, CancellationToken cancellationToken) { _deletePost = await GetPost(request.Id); await _postRepository.DeleteAsync(_deletePost); return(Unit.Value); }
public async Task <long> Handle(AddPostCommand request, CancellationToken cancellationToken) { _newPost = CreateNewPost(request); await _postRepository.AddAsync(_newPost); await _postRepository.SaveChangesAsync(); return(_newPost.Id); }
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); }
private void UpdatePost(UpdatePostCommand model, dbEntities.Post dbPost) { _mapper.Map(model, dbPost); dbPost.LastModifiedAt = DateTime.UtcNow; }
private void UpdatePost(UpdatePostCommand model, dbEntities.Post dbPost) { _mapper.Map(model, dbPost); }