public int Add(AddAnnualPlanInput input) { var userId = _authInfoProvider.GetCurrent().User.Id; if (!_projectHelper.HasPermission("项目计划负责人", input.ProjectId))//权限设置 { throw new AppCoreException("年计划发布没有权限"); } var plan = input.MapTo <AnnualPlan>(); if (plan.RecordDate == null) { throw new AppCoreException("传入数据的Year不能为空"); } 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("yyyy"), "InvestmentAnnualPlan", "已存在"); } _planRepository.Add(plan); return(plan.Id); }
public IActionResult Add([FromBody] AddAnnualPlanInput input) { int id = _planService.Add(input); return(Created("", new { id })); }