public void GetAllTransactionsGroups() { CompanyFixture.SaveNewMSZCompany(); // TransactionGroup tran = CreateNewTransactionGroup(); GroupController controller = new GroupController(); ICollection<TransactionGroup> groups = controller.GetAllGroups(); Assert.IsNotEmpty((ICollection)groups); }
public Transaction AddNewTransaction(DateTime date, string companyId, int amount, decimal price, bool buy, decimal fee, int groupId) { CompanyController companyController = new CompanyController(); GroupController groupController = new GroupController(); Transaction t = new Transaction(); #region checking if company symbol exists in table, if not then we must add it Company company = companyController.GetCompany(companyId); if (company == null) { companyController.AddNewCompany(companyId, "brak"); } #endregion #region processing TransactionGroup TransactionGroup group = null; if(groupId == 0) //adding new group { group = groupController.AddNewTransGroup(companyId); } else { group = groupController.GetGroup(groupId); if (group == null) { groupController.AddNewTransGroup(companyId); } } #endregion t.Amount = amount; t.Price = price; t.Fee = fee; t.Date = date; t.Group = group; t.GroupId = group.ID; t.Value = price * amount + fee; ; t.Buy = buy; try { t = Repository<Transaction>.Save(t); UnitOfWork.Current.TransactionalFlush(); } catch (Exception ex) { UnitOfWork.CurrentSession.Clear(); throw; } //t = Repository<Transaction>.Get(t.ID); return t; }
private void btnGroup_Click(object sender, EventArgs e) { if (transactionsIds.Count <= 0) return; //assing using (IUnitOfWork unit = UnitOfWork.Start()) { GroupController contr = new GroupController(); contr.AssignTransactionsToGroup(transactionsIds, MinGroupValue); bindingSource1.DataSource = GetTransactions(unit); dataGridView1.DataSource = bindingSource1.DataSource; transactionsIds.Clear(); //clear the collection } // using (IUnitOfWork unit = UnitOfWork.Start()) { GroupController contr = new GroupController(); ICollection<Transaction> tran = contr.GetAllTransactionForGroup(1); } }
public void GetAllTransactionsByGroupId() { Company c = CompanyFixture.SaveNewMSZCompany(); TransactionGroup group = GroupFixture.CreateNewTransactionGroup(); Transaction tran = TransactionFixture.CreateNewTransaction(1); UnitOfWork.Current.TransactionalFlush(); UnitOfWork.CurrentSession.Evict(tran); UnitOfWork.CurrentSession.Evict(group); UnitOfWork.CurrentSession.Evict(c); GroupController controller = new GroupController(); ICollection<TransactionGroup> groups = controller.GetAllGroups(); Assert.IsNotEmpty((ICollection)groups); TransactionController tr = new TransactionController(); ICollection<Transaction> transactions = tr.GetAllTransaction(); Assert.IsNotEmpty((ICollection)transactions); transactions = controller.GetAllTransactionForGroup(1); Assert.IsNotEmpty((ICollection)transactions); }
public void AssignTransactionsToGroup() { PrepareData(); TransactionController tr = new TransactionController(); GroupController gc = new GroupController(); //only 1 transaction assigned to group 1 //ICollection<Transaction> transactions = null; ICollection<Transaction> transactions = gc.GetAllTransactionForGroup(2); Assert.IsTrue(transactions.Count == 1); UnitOfWork.Current.TransactionalFlush(); UnitOfWork.CurrentSession.Evict(transactions); UnitOfWork.CurrentSession.Clear(); //assign 2 other transactions gc.AssignTransactionsToGroup(new List<int>() { 1, 2 }, 2); //should be 3 transactions = gc.GetAllTransactionForGroup(2); Assert.IsTrue(transactions.Count == 3); }