示例#1
0
        public async Task <IResult> Update(CommentForAddUpdateDto dto)
        {
            var isCommentExists = await _commentDal.GetAsync(c => c.Id == dto.Id);

            if (isCommentExists == null)
            {
                return(new ErrorResult(Messages.CommentNotFound));
            }
            await _commentDal.UpdateAsync(dto.Map(isCommentExists));

            return(new SuccessResult(Messages.UpdatedSuccessfully));
        }
        public async Task <BasexResponse <Comment> > DeleteByIdAsync(int commentId)
        {
            try
            {
                var comment = await _commentDal.GetAsync(commentId);

                _commentDal.Delete(comment);
                await _unitOfWork.CompleteAsync();

                return(new BasexResponse <Comment>(comment));
            }
            catch (Exception ex)
            {
                return(new BasexResponse <Comment>(ex.Message));
            }
        }