private void Save() { try { decimal allocatedamount = LineItems.Sum(s => s.Amount); if (allocatedamount != TotalUnderbankingAmout) { MessageBox.Show("Please make sure the whole amount is allocated"); return; } using (var container = NestedContainer) { var wf = Using<IReCollectionWFManager>(container); var config = Using<IConfigService>(container).Load(); ReCollection doc = new ReCollection(Guid.NewGuid()); doc.CostCentreId = Salesman.Id; doc.CostCentreApplicationId = config.CostCentreApplicationId; doc.RecepientCostCentreId = config.CostCentreId; foreach (var i in LineItems) { UnderBankingItem item = new UnderBankingItem(Guid.NewGuid()); item.Amount = i.Amount; item.Description = i.Description; item.FromCostCentreId = i.CostCentre.Id; doc.AddLineItem(item); } wf.SubmitChanges(doc); MessageBox.Show("Under banking Saved successfully"); } }catch(Exception ex) { MessageBox.Show("ERROR "+ex.Message); return; } Status = true; RequestClose(this, EventArgs.Empty); }
private static void TestReCollectionCommand() { var wf = ObjectFactory.GetInstance<IReCollectionWFManager>(); var cost = ObjectFactory.GetInstance<ICostCentreRepository>().GetAll().First(); var config = ObjectFactory.GetInstance<IConfigService>().Load(); ReCollection doc = new ReCollection(Guid.NewGuid() ); doc.CostCentreId = cost.Id; doc.CostCentreApplicationId = config.CostCentreApplicationId; UnderBankingItem item= new UnderBankingItem(Guid.NewGuid()); item.Amount = 200; item.FromCostCentreId = cost.Id; doc.AddLineItem(item); wf.SubmitChanges(doc); }