示例#1
0
        public int Add(AddMonthlyPlanInput input)
        {
            var userId = _authInfoProvider.GetCurrent().User.Id;

            if (!_projectHelper.HasPermission("项目计划负责人", input.ProjectId))//权限设置
            {
                throw new AppCoreException("月计划发布没有权限");
            }
            var plan = input.MapTo <MonthlyPlan>();

            if (plan.RecordDate == null)
            {
                throw new AppCoreException("传入数据的RecordTime不能为空");
            }
            if (plan.ProjectId == 0)
            {
                throw new AppCoreException("传入数据的ProjectId不能为空");
            }
            if (_planRepository.Count(u => u.ProjectId == plan.ProjectId && u.RecordDate == plan.RecordDate) > 0)
            {
                throw new EntityException("RecordDate", plan.RecordDate.ToString("y"), "InvestmentMonthlyPlan", "已存在");
            }
            _planRepository.Add(plan);
            return(plan.Id);
        }
示例#2
0
        public IActionResult Add([FromBody] AddMonthlyPlanInput input)
        {
            int id = _planService.Add(input);

            return(Created("", new { id }));
        }