Example #1
0
 /// <summary>
 ///     增加供应商角色。
 /// </summary>
 /// <param name="supplierCompany"></param>
 private void AddSupplierCompanyRole(SupplierCompanyDTO supplierCompany)
 {
     SupplierCompany supplierCmy = _supplierCompanyRepository.Get(supplierCompany.SupplierCompanyId);
     if (supplierCmy == null) throw new Exception("找不到合作公司。");
     supplierCompany
         //新增飞机租赁供应商角色
         .If(p => p.AircraftLeaseSupplier, p =>
         {
             SupplierRole aircraftLeaseSupplier =
                 _supplierRoleRepository.GetSupplierRoleBySupplierCmpyId(typeof (AircraftLeaseSupplier),
                     p.SupplierCompanyId);
             if (aircraftLeaseSupplier != null) return;
             AircraftLeaseSupplier newAircraftLeaseSupplier =
                 SupplierRoleFactory.CreateAircraftLeaseSupplier(supplierCmy);
             _supplierRoleRepository.Add(newAircraftLeaseSupplier);
         })
         //新增飞机购买供应商角色
         .If(p => p.AircraftPurchaseSupplier, p =>
         {
             SupplierRole aircraftPurchaseSupplier =
                 _supplierRoleRepository.GetSupplierRoleBySupplierCmpyId(typeof (AircraftPurchaseSupplier),
                     p.SupplierCompanyId);
             if (aircraftPurchaseSupplier != null) return;
             AircraftPurchaseSupplier newAircraftPurchaseSupplier =
                 SupplierRoleFactory.CreateAircraftPurchaseSupplier(supplierCmy);
             _supplierRoleRepository.Add(newAircraftPurchaseSupplier);
         })
         //新增发动机租赁供应商角色
         .If(p => p.EngineLeaseSupplier, p =>
         {
             SupplierRole engineLeaseSupplier =
                 _supplierRoleRepository.GetSupplierRoleBySupplierCmpyId(typeof (EngineLeaseSupplier),
                     p.SupplierCompanyId);
             if (engineLeaseSupplier != null) return;
             EngineLeaseSupplier newEngineLeaseSupplier =
                 SupplierRoleFactory.CreateEngineLeaseSupplier(supplierCmy);
             _supplierRoleRepository.Add(newEngineLeaseSupplier);
         })
         //新增发动机购买供应商角色
         .If(p => p.EnginePurchaseSupplier, p =>
         {
             SupplierRole enginePurchaseSupplier =
                 _supplierRoleRepository.GetSupplierRoleBySupplierCmpyId(typeof (EnginePurchaseSupplier),
                     p.SupplierCompanyId);
             if (enginePurchaseSupplier != null) return;
             EnginePurchaseSupplier newEnginePurchaseSupplier =
                 SupplierRoleFactory.CreateEnginePurchaseSupplier(supplierCmy);
             _supplierRoleRepository.Add(newEnginePurchaseSupplier);
         })
         //新增BFE供应商角色
         .If(p => p.BFEPurchaseSupplier, p =>
         {
             SupplierRole bfePurchaseSupplier =
                 _supplierRoleRepository.GetSupplierRoleBySupplierCmpyId(typeof (BFEPurchaseSupplier),
                     p.SupplierCompanyId);
             if (bfePurchaseSupplier != null) return;
             BFEPurchaseSupplier newBfePurchaseSupplier =
                 SupplierRoleFactory.CreateBFEPurchaseSupplier(supplierCmy);
             _supplierRoleRepository.Add(newBfePurchaseSupplier);
         })
         //新增维修物料角色
         .If(p => p.MaintainSupplier, p =>
         {
             SupplierRole maintainPurchaseSupplier =
                 _supplierRoleRepository.GetSupplierRoleBySupplierCmpyId(typeof (MaintainSupplier),
                     p.SupplierCompanyId);
             if (maintainPurchaseSupplier != null) return;
             MaintainSupplier newMaintainPurchaseSupplier =
                 SupplierRoleFactory.CreateMaintainSupplier(supplierCmy);
             _supplierRoleRepository.Add(newMaintainPurchaseSupplier);
         })
         //新增其他角色
         .If(p => p.OtherSupplier, p =>
         {
             SupplierRole otherSupplier =
                 _supplierRoleRepository.GetSupplierRoleBySupplierCmpyId(typeof (OtherSupplier),
                     p.SupplierCompanyId);
             if (otherSupplier != null) return;
             OtherSupplier newOtherSupplier = SupplierRoleFactory.CreateOtherSupplier(supplierCmy);
             _supplierRoleRepository.Add(newOtherSupplier);
         });
 }
Example #2
0
 /// <summary>
 ///     删除供应商角色。
 /// </summary>
 /// <param name="supplierCompany"></param>
 private void RemoveSupplierCompanyRole(SupplierCompanyDTO supplierCompany)
 {
     SupplierCompany supplierCmy = _supplierCompanyRepository.Get(supplierCompany.SupplierCompanyId);
     if (supplierCmy == null) throw new Exception("找不到合作公司。");
     supplierCompany
         //删除飞机租赁供应商角色
         .If(p => !p.AircraftLeaseSupplier, p =>
         {
             SupplierRole aircraftLeaseSupplier =
                 _supplierRoleRepository.GetSupplierRoleBySupplierCmpyId(typeof (AircraftLeaseSupplier),
                     p.SupplierCompanyId);
             if (aircraftLeaseSupplier != null)
             {
                 _supplierRoleRepository.Remove(aircraftLeaseSupplier);
             }
         })
         //删除飞机购买供应商角色
         .If(p => !p.AircraftPurchaseSupplier, p =>
         {
             SupplierRole aircraftPurchaseSupplier =
                 _supplierRoleRepository.GetSupplierRoleBySupplierCmpyId(typeof (AircraftPurchaseSupplier),
                     p.SupplierCompanyId);
             if (aircraftPurchaseSupplier != null)
             {
                 _supplierRoleRepository.Remove(aircraftPurchaseSupplier);
             }
         })
         //删除发动机租赁供应商角色
         .If(p => !p.EngineLeaseSupplier, p =>
         {
             SupplierRole engineLeaseSupplier =
                 _supplierRoleRepository.GetSupplierRoleBySupplierCmpyId(typeof (EngineLeaseSupplier),
                     p.SupplierCompanyId);
             if (engineLeaseSupplier != null)
             {
                 _supplierRoleRepository.Remove(engineLeaseSupplier);
             }
         })
         //删除发动机购买供应商角色
         .If(p => !p.EnginePurchaseSupplier, p =>
         {
             SupplierRole enginePurchaseSupplier =
                 _supplierRoleRepository.GetSupplierRoleBySupplierCmpyId(typeof (EnginePurchaseSupplier),
                     p.SupplierCompanyId);
             if (enginePurchaseSupplier != null)
             {
                 _supplierRoleRepository.Remove(enginePurchaseSupplier);
             }
         })
         //删除BFE供应商角色
         .If(p => !p.BFEPurchaseSupplier, p =>
         {
             SupplierRole bfePurchaseSupplier =
                 _supplierRoleRepository.GetSupplierRoleBySupplierCmpyId(typeof (BFEPurchaseSupplier),
                     p.SupplierCompanyId);
             if (bfePurchaseSupplier != null)
             {
                 _supplierRoleRepository.Remove(bfePurchaseSupplier);
             }
         })
         //删除维修供应商角色
         .If(p => !p.MaintainSupplier, p =>
         {
             SupplierRole maintainSupplierPurchaseSupplier =
                 _supplierRoleRepository.GetSupplierRoleBySupplierCmpyId(typeof (MaintainSupplier),
                     p.SupplierCompanyId);
             if (maintainSupplierPurchaseSupplier != null)
             {
                 _supplierRoleRepository.Remove(maintainSupplierPurchaseSupplier);
             }
         })
         //删除其他供应商角色
         .If(p => !p.OtherSupplier, p =>
         {
             SupplierRole otherSupplier =
                 _supplierRoleRepository.GetSupplierRoleBySupplierCmpyId(typeof (OtherSupplier),
                     p.SupplierCompanyId);
             if (otherSupplier != null)
             {
                 _supplierRoleRepository.Remove(otherSupplier);
             }
         });
 }
Example #3
0
 public void ModifySupplierCompany(SupplierCompanyDTO supplierCompany)
 {
     if (supplierCompany.IsNull()) throw new ArgumentNullException("supplierCompany");
     AddSupplierCompanyRole(supplierCompany);
     RemoveSupplierCompanyRole(supplierCompany);
 }