public void AddCostin(ProjectCostInDto dto) { if (string.IsNullOrEmpty(dto.Title)) { throw new LogicException("摘要 爲空"); } if (dto.ProjectId == 0) { throw new LogicException("項目 爲空"); } var project = repository.GetProjectMaster(dto.ProjectId); if (project == null) { throw new LogicException("項目 不存在"); } ProjectCostIn entity = dto.ProjectedAs <ProjectCostIn>(); entity.Created(this); repository.AddCostin(entity); repository.UnitOfWork.Commit(); }