public void ActivateDimension <TResult>(TResult obj) where TResult : class { var resultType = typeof(TResult); if (resultType == typeof(Customer)) { var command = new ActivateCustomerCommand { Customer = obj as Customer }; _processXml.Process(command.ToXml()); } if (resultType == typeof(Supplier)) { var command = new ActivateSupplierCommand { Supplier = obj as Supplier }; _processXml.Process(command.ToXml()); } if (resultType == typeof(BalanceSheet)) { var command = new ActivateGeneralLedgerCommand { GeneralLedger = obj as BalanceSheet }; _processXml.Process(command.ToXml()); } if (resultType == typeof(ProfitLoss)) { var command = new ActivateGeneralLedgerCommand { GeneralLedger = obj as ProfitLoss }; _processXml.Process(command.ToXml()); } if (resultType == typeof(CostCenter)) { var command = new ActivateCostCenterCommand { CostCenter = obj as CostCenter }; _processXml.Process(command.ToXml()); } if (resultType == typeof(Article)) { var command = new ActivateArticleCommand { Article = obj as Article }; _processXml.Process(command.ToXml()); } }
public async Task <string> Handle(ActivateSupplierCommand cmd) { var supplier = (await supplierRepository.QuerySupplier(new SupplierSearchQuery { SupplierId = cmd.SupplierId, })).Items.SingleOrDefault(m => m.Id == cmd.SupplierId); if (supplier == null) { throw new NotFoundException($"Supplier {cmd.SupplierId} not found", cmd.SupplierId); } supplier.Status = Resources.Suppliers.SupplierStatus.Active; var res = await supplierRepository.ManageSupplier(new SaveSupplier { Supplier = supplier }); return(res.SupplierId); }