コード例 #1
0
        public async Task <CaseCommentDTO> EditAsync([FromBody] CaseCommentDTO model)
        {
            if (!TryValidateModel(model))
            {
                throw new Exception("400");
            }

            return(await _caseCommentService.EditAsync(model));
        }
コード例 #2
0
        public async Task <BaseModel> CreateAsync([FromBody] CaseCommentDTO model)
        {
            if (!TryValidateModel(model))
            {
                throw new Exception("400");
            }

            var id = await _caseCommentService.CreateAsync(model);

            return(IdResponse(id));
        }
コード例 #3
0
        public async Task <Guid> CreateAsync(CaseCommentDTO model)
        {
            var entity = new CaseComment()
            {
                Id        = Guid.NewGuid(),
                UserId    = model.UserId,
                CaseId    = model.CaseId,
                Comment   = model.Comment,
                CreatedAt = model.CreatedAt
            };

            await _caseCommentRepository.InsertAsync(entity);

            await _caseCommentRepository.SaveAsync();

            return(entity.Id);
        }
コード例 #4
0
        public async Task <CaseCommentDTO> EditAsync(CaseCommentDTO model)
        {
            var entity = await _caseCommentRepository.GetByIdAsync(model.Id);

            if (entity == null)
            {
                throw new Exception("Comment not found");
            }

            entity.Id        = model.Id;
            entity.UserId    = model.UserId;
            entity.CaseId    = model.CaseId;
            entity.Comment   = model.Comment;
            entity.CreatedAt = model.CreatedAt;
            _caseCommentRepository.Update(entity);
            await _caseCommentRepository.SaveAsync();

            return(entity.ToModel());
        }