public async Task <CaseCommentDTO> EditAsync([FromBody] CaseCommentDTO model) { if (!TryValidateModel(model)) { throw new Exception("400"); } return(await _caseCommentService.EditAsync(model)); }
public async Task <BaseModel> CreateAsync([FromBody] CaseCommentDTO model) { if (!TryValidateModel(model)) { throw new Exception("400"); } var id = await _caseCommentService.CreateAsync(model); return(IdResponse(id)); }
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); }
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()); }