public IActionResult GetByPostId(int id) { var cmt = _commentAppService.GetByPostId(id); if (cmt == null) { throw new Exception("Không tồn tại Id= " + id + " trong bảng comment"); } else { return(Ok(cmt)); } }
public IActionResult Delete(int id) { var cmt = _commentAppService.GetByPostId(id); if (_postAppService.GetById(id) == null) { throw new Exception("Không tồn tại Id"); } else { if (cmt == null) { var post = _postAppService.Delete(id); return(Ok()); } else { throw new Exception("PosId bên bảng comment tồn tại"); } } }