Exemplo n.º 1
0
 public void FlowSettings(UnitFlowSettingsModel unitFlowSettingsModel)
 {
     ValidatorFlowSettingsModel(unitFlowSettingsModel);
     var unit = _unitRepository.Find(unitFlowSettingsModel.Id);
     unit.UnitFlowSettings = unit.UnitFlowSettings ?? new UnitFlowSettings();
     unit.UnitFlowSettings.Unit = unit;
     unit.UnitFlowSettings.GovUnit = _unitRepository.Find(unitFlowSettingsModel.GovUnitId.Value);
     unit.UnitFlowSettings.NpcUnit = _unitRepository.Find(unitFlowSettingsModel.NpcUnitId.Value);
     unit.UnitFlowSettings.SponsorUnits.Clear();
     unit.UnitFlowSettings.SubsidiaryUnits.Clear();
     unitFlowSettingsModel.SponsorUnitIdString.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries).ToList().ForEach(unitId => unit.UnitFlowSettings.SponsorUnits.Add(_unitRepository.Find(Guid.Parse(unitId))));
     unitFlowSettingsModel.SubsidiaryUnitString.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries).ToList().ForEach(unitId =>
      unit.UnitFlowSettings.SubsidiaryUnits.Add(_unitRepository.Find(Guid.Parse(unitId))));
     _unitRepository.Save(unit);
 }
Exemplo n.º 2
0
 public ActionResult UnitFlowSettingsPost(UnitFlowSettingsModel unitFlowSettingsModel)
 {
     try
     {
         _unitAction.FlowSettings(unitFlowSettingsModel);
     }
     catch (Exception exception)
     {
         return RedirectToMessage("设置时出错:" + exception.Message);
     }
     return RedirectToMessage("设置成功");
 }
Exemplo n.º 3
0
 public UnitFlowSettingsModel InitializeUnitFlowSettingsModel(Guid id)
 {
     var unit = _unitRepository.Find(id);
     var model = new UnitFlowSettingsModel();
     model.Id = id;
     model.Unit = unit;
     if (unit.UnitFlowSettings != null)
     {
         model.NpcUnitId = unit.UnitFlowSettings.NpcUnit.Id;
         model.GovUnitId = unit.UnitFlowSettings.GovUnit.Id;
         model.SponsorUnitIdString = string.Join(",", unit.UnitFlowSettings.SponsorUnits.Select(o => o.Id));
         model.SubsidiaryUnitString = string.Join(",", unit.UnitFlowSettings.SubsidiaryUnits.Select(o => o.Id));
     }
     return model;
 }
Exemplo n.º 4
0
        private void ValidatorFlowSettingsModel(UnitFlowSettingsModel unitFlowSettingsModel)
        {
            var govUnit = _unitRepository.Find(unitFlowSettingsModel.GovUnitId.Value);
            if (govUnit == null)
            {
                throw new ApplicationException("政府办公室Id不正确,请核实");
            }
            var npcUnit = _unitRepository.Find(unitFlowSettingsModel.NpcUnitId.Value);
            if (npcUnit == null)
            {
                throw new ApplicationException("人大办Id不正确,请核实");
            }
            unitFlowSettingsModel.SponsorUnitIdString.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries).ToList().ForEach(unitId =>
            {
                var sponsorUnit = _unitRepository.Find(Guid.Parse(unitId));
                if (sponsorUnit == null)
                {
                    throw new ApplicationException("主办单位id中" + unitId + "未找到与之对应的组织");
                }

            });
            unitFlowSettingsModel.SubsidiaryUnitString.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries).ToList().ForEach(unitId =>
            {
                var subsidiaryUnit = _unitRepository.Find(Guid.Parse(unitId));
                if (subsidiaryUnit == null)
                {
                    throw new ApplicationException("协办单位id中" + unitId + "未找到与之对应的组织");
                }

            });
        }