示例#1
0
        public void EditCostout(long id, ProjectCostOutDto dto)
        {
            ProjectCostOut entity = repository.GetCostout(id);

            if (entity == null)
            {
                throw new LogicException("支出项目为空");
            }
            if (dto.ProjectId == 0)
            {
                throw new LogicException("項目 爲空");
            }
            if (string.IsNullOrEmpty(dto.Title))
            {
                throw new LogicException("摘要 爲空");
            }
            if (string.IsNullOrEmpty(dto.CostoutDate))
            {
                throw new LogicException("日期 爲空");
            }
            var project = repository.GetProjectMaster(dto.ProjectId);

            if (project == null)
            {
                throw new BingoX.LogicException("項目 不存在");
            }
            decimal projectExpendAmount = repository.GetProjectExpendAmount(dto.ProjectId);

            projectExpendAmount = projectExpendAmount - entity.ExpendAmount;

            entity.CopyFromGroup(dto.ProjectedAs <ProjectCostOut>(), "Info");
            repository.UpdateCostout(entity);
            repository.UnitOfWork.Commit();
        }
示例#2
0
        public void AddCostout(ProjectCostOutDto dto)
        {
            if (dto.ProjectId == 0)
            {
                throw new BingoX.LogicException("項目 爲空");
            }
            if (string.IsNullOrEmpty(dto.Title))
            {
                throw new BingoX.LogicException("摘要 爲空");
            }
            if (string.IsNullOrEmpty(dto.CostoutDate))
            {
                throw new BingoX.LogicException("日期 爲空");
            }
            var project = repository.GetStandingbook(dto.ProjectId);

            if (project == null)
            {
                throw new BingoX.LogicException("項目 不存在");
            }
            decimal projectExpendAmount = repository.GetProjectExpendAmount(dto.ProjectId);

            ProjectCostOut entity = dto.ProjectedAs <ProjectCostOut>();

            entity.Created(this);
            repository.AddCostout(entity);
            repository.UnitOfWork.Commit();
        }
示例#3
0
 public void EditCostout([FromServices] CostInOutService service, [FromBody] ProjectCostOutDto dto, [FromRoute] long id)
 {
     service.EditCostout(id, dto);
 }
示例#4
0
 public void AddCostout([FromServices] CostInOutService service, [FromBody] ProjectCostOutDto dto)
 {
     service.AddCostout(dto);
 }