public void DateChangeAfter() { // Expecting a minimal change in position. // If moving the item up, it should end up BELOW items with the same date. TransactionList tl = new TransactionList(); tl.Add(newTx("2012-02-10")); tl.Add(newTx("2012-02-15")); Transaction tx = newTx("2012-02-05"); tl.Add(tx); AssertAtIndex(tl, 0, tx); // Different date, easy case tx.Date = new DateTime(2012, 02, 5); tx.Date = new DateTime(2012, 02, 12); AssertAtIndex(tl, 1, tx); // Different date, easy case tx.Date = new DateTime(2012, 02, 5); tx.Date = new DateTime(2012, 02, 20); AssertAtIndex(tl, 2, tx); // Same date, should come BEFORE the bottom one, coming from above tx.Date = new DateTime(2012, 02, 5); tx.Date = new DateTime(2012, 02, 15); AssertAtIndex(tl, 1, tx); // Same date, should come BEFORE the bottom-1 one, coming from below tx.Date = new DateTime(2012, 02, 5); tx.Date = new DateTime(2012, 02, 10); AssertAtIndex(tl, 0, tx); }
public void AddTxEarlier() { TransactionList tl = new TransactionList(); tl.Add(newTx("2012-02-10")); AssertInOrder(tl); tl.Add(newTx("2012-02-01")); AssertInOrder(tl); Assert.AreEqual(2, tl.Count); }
private void SyncLists() { originalTransactionList = new TransactionList(); foreach (var item in App.Instance.TransDataSource.TransactionList) originalTransactionList.Add(item); }
public void GetTransactionsFromDatabase(TransactionDatabase transactionDatabase) { foreach (var transactionDatabaseTransaction in transactionDatabase.Transactions) { TransactionList.Add(transactionDatabaseTransaction); } }
internal static TransactionList getTransactionList(HttpResponseMessage responce) { var transactionList = new TransactionList(); var jsonObj = JsonConvert.DeserializeObject <Dictionary <string, object> >(responce.Content.ReadAsStringAsync().Result); if (jsonObj.ContainsKey("banktransactions")) { var transactionArray = JsonConvert.DeserializeObject <List <object> >(jsonObj["banktransactions"].ToString()); foreach (var transactionObj in transactionArray) { var transaction = new Transaction(); transaction = JsonConvert.DeserializeObject <Transaction>(transactionObj.ToString()); transactionList.Add(transaction); } } if (jsonObj.ContainsKey("page_context")) { var pageContext = new PageContext(); pageContext = JsonConvert.DeserializeObject <PageContext>(jsonObj["page_context"].ToString()); transactionList.page_context = pageContext; } return(transactionList); }
public void AddTransaction(FranchiseTransaction transaction) { TransactionList.Add(new TransactionDetailViewModel() { Data = transaction }); }
public bool addNewTransaction(int userID, DateTime transactionDate, double transactionCost, double tax, string paymentMethod) { try { int maxTransactionId = 0; int maxCustomerId = 0; //need some code to avoid dulicate usernames //maybe add some logic (busiess rules) about password policy //IUser user = new User(name, password, userType); // Construct a User Object foreach (Transaction transaction in TransactionList) { if (transaction.TransactionID > maxTransactionId) { maxTransactionId = transaction.TransactionID; } if (transaction.CustomerID > maxCustomerId) { maxCustomerId = transaction.CustomerID; } } ITransaction theTransaction = TransactionFactory.GetTransaction(maxTransactionId + 1, maxCustomerId + 1, userID, transactionDate, transactionCost, paymentMethod, tax); // Using a Factory to create the user entity object. ie seperating object creation from business logic TransactionList.Add(theTransaction); // Add a reference to the newly created object to the Models UserList DataLayer.addNewTransactionToDB(theTransaction); //Gets the DataLayer to add the new user to the DB. return(true); } catch (System.Exception excep) { return(false); } }
public async Task Init() { var UserID = SignedInUser.User.UserID; var req = new TransactionSearchRequest { UserID = UserID, From = _from, To = _to }; TransactionList.Clear(); var list = await transactionService.Get <List <MTransaction> >(req); var user = await userService.GetById <MUser>(UserID); if (list.Count() != 0) { foreach (var x in list) { var course = await courseService.GetById <MCourse>(x.CourseID); if (x.UserID == user.UserID) { x.CourseName = course.Name; x.TransactionDateString = x.TransactionDate.ToString("dd/MM/yyyy"); TransactionList.Add(x); } } } }
public void testTagNameChanges() { // Create a Transaction element and show its version-dependent tag name Transaction trans = new Transaction(); assertTransactionInfo(trans); TransactionList tl = new TransactionList(); tl.Add(trans); assertTransactionInfo(trans); }
public Car RaiseCarBalance(int id, int sum) { try { var car = CarList.SingleOrDefault(c => c.Id == id); car.ChangeBalance(sum, true); Console.WriteLine("Balance for car with id {0} was raised by {1}", id, sum); TransactionList.Add(new Transaction(id, sum)); return(car); } catch (ArgumentNullException) { Console.WriteLine("Something went wrong"); } return(null); }
public static TransactionList GetTransactionsByCustomer(int CustomerId) { TransactionList list = new TransactionList(); SqlParamsColl paramList = new SqlParamsColl(); paramList.Add("@CustomerId", SqlDbType.Int, CustomerId); SqlTools.ExecuteReader("dbo.Admin_LoadCustomerTransactions", paramList, reader => { while (reader.Read()) { list.Add(PopulateObjectFromReader(reader)); } }); return list; }
public void PraseTransactionInfo(string jsonStr) { JsonObject jsonObject = JsonObject.Parse(jsonStr); foreach (var item in jsonObject["jsonData"].GetObject()["pageData"].GetArray()) { var record = item.GetObject(); RecordEntity temp = new RecordEntity(); temp.machineId = record.GetNamedString("machineId"); temp.smtDealDateTimeTxt = record.GetNamedString("smtDealDateTimeTxt"); temp.smtDealName = record.GetNamedString("smtDealName"); temp.smtOutMoney = record.GetNamedNumber("smtOutMoney").ToString(); temp.smtTransMoney = record.GetNamedNumber("smtTransMoney").ToString(); temp.smtOrgName = record.GetNamedString("smtOrgName"); TransactionList.Add(temp); } }
public static void AddTransaction() { Console.WriteLine(); Console.Write("Enter the year of the transaction: "); ushort year = Convert.ToUInt16(Console.ReadLine()); Console.Write("Enter the month of the transaction: "); byte month = Convert.ToByte(Console.ReadLine()); Console.Write("Enter the day of the transaction: "); byte day = Convert.ToByte(Console.ReadLine()); Console.Write("Enter the amount of the transaction: "); double amount = Convert.ToDouble(Console.ReadLine()); Console.Write("Enter the description of the transaction: "); string description = Console.ReadLine(); transactionList.Add( new Transaction(day, month, year, amount, description)); }
internal static TransactionList getTransactionList(HttpResponseMessage responce) { var transactionList = new TransactionList(); var jsonObj = JsonConvert.DeserializeObject<Dictionary<string, object>>(responce.Content.ReadAsStringAsync().Result); if (jsonObj.ContainsKey("transactions")) { var transactionArray = JsonConvert.DeserializeObject<List<object>>(jsonObj["transactions"].ToString()); foreach (var transactionObj in transactionArray) { var transaction = new Transaction(); transaction = JsonConvert.DeserializeObject<Transaction>(transactionObj.ToString()); transactionList.Add(transaction); } } if (jsonObj.ContainsKey("page_context")) { var pageContext = new PageContext(); pageContext = JsonConvert.DeserializeObject<PageContext>(jsonObj["page_context"].ToString()); transactionList.page_context = pageContext; } return transactionList; }
public static TransactionList GetAccountTransactions(int AccountNumber) { TransactionList list = new TransactionList(); SqlParamsColl paramList = new SqlParamsColl(); decimal feeAmount = 0; try { feeAmount = Decimal.Parse(ConfigurationManager.AppSettings["Fee_TransactionHistory"]); } catch (FormatException) { } paramList.Add("@AccountNumber", SqlDbType.Int, AccountNumber); paramList.Add("@FeeAmount", SqlDbType.Money, feeAmount); SqlTools.ExecuteReader("Account_RetrieveTransactions", paramList, reader => { while (reader.Read()) { list.Add(PopulateObjectFromReader(reader)); } }); return list; }
static void Main(string[] args) { const int SIZE = 1000; TransactionList tList = new TransactionList(); RepetitiveTransactionList rList = new RepetitiveTransactionList(); bool finished = false; do { switch (MainMenu()) { case '1': Console.WriteLine("Day: "); int day = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("Month: "); int month = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("Year: "); int year = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("Amount: "); int amount = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("Description: "); string description = Console.ReadLine(); tList.Add( new Transaction(day, month, year, amount, description) ); break; case '2': Console.WriteLine("Day: "); int rday = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("Month: "); int rmonth = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("Amount: "); int ramount = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("Description: "); string rdescription = Console.ReadLine(); rList.Add( new RepetitiveTransaction (rday, rmonth, ramount, rdescription) ); break; case '3': Console.WriteLine("Month: "); int sMonth = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("Year: "); int sYear = Convert.ToInt32(Console.ReadLine()); int size = tList.GetLength(); for (int i = 0; i < size; i++) { if (tList.GetTransaction(i).Contains("" + sMonth) && tList.GetTransaction(i).Contains("" + sYear)) { Console.WriteLine(tList.GetTransaction(i)); } } size = rList.GetLength(); for (int i = 0; i < size; i++) { if (rList.GetTransaction(i).Contains("" + sMonth) && rList.GetTransaction(i).Contains("" + sYear)) { Console.WriteLine(rList.GetTransaction(i)); } } break; break; case '4': Console.WriteLine("Enter text to search: "); string search = Console.ReadLine(); int sSize = tList.GetLength(); for (int i = 0; i < sSize; i++) { if (tList.GetTransaction(i).Contains(search)) { ; } Console.WriteLine(tList.GetTransaction(i)); } size = rList.GetLength(); for (int i = 0; i < sSize; i++) { if (rList.GetTransaction(i).Contains(search)) { Console.WriteLine(tList.GetTransaction(i)); } } break; case 'Q': finished = true; break; } } while (!finished); }
public void DateChangeBefore() { // Expecting a minimal change in position. // If moving the item up, it should end up BELOW items with the same date. TransactionList tl = new TransactionList(); tl.Add(newTx("2012-02-10")); tl.Add(newTx("2012-02-15")); Transaction tx = newTx("2012-02-20"); tl.Add(tx); AssertAtIndex(tl, 2, tx); // Different date, easy case tx.Date = new DateTime(2012, 02, 20); tx.Date = new DateTime(2012, 02, 12); AssertAtIndex(tl, 1, tx); // Different date, easy case tx.Date = new DateTime(2012, 02, 20); tx.Date = new DateTime(2012, 02, 05); AssertAtIndex(tl, 0, tx); // Same date, should come AFTER that first one, coming from below tx.Date = new DateTime(2012, 02, 20); tx.Date = new DateTime(2012, 02, 10); AssertAtIndex(tl, 1, tx); // Same date, should come AFTER the second one, coming from below tx.Date = new DateTime(2012, 02, 20); tx.Date = new DateTime(2012, 02, 15); AssertAtIndex(tl, 2, tx); }
public void DateChangeWithinInterval() { TransactionList tl = new TransactionList(); tl.Add(newTx("2012-02-01")); Transaction tx = newTx("2012-02-10"); tl.Add(tx); tl.Add(newTx("2012-02-20")); AssertInOrder(tl); AssertAtIndex(tl, 1, tx); tx.Date = new DateTime(2012, 02, 8); AssertInOrder(tl); AssertAtIndex(tl, 1, tx); // Don't push before prev tx.Date = tl[0].Date; AssertInOrder(tl); AssertAtIndex(tl, 1, tx); // Don't put after next tx.Date = tl[2].Date; AssertInOrder(tl); AssertAtIndex(tl, 1, tx); }
/// <summary> /// Метод загрузки отчета о трансфере с карты на карту в логлист /// </summary> /// <param name="source">источник</param> /// <param name="args">аргументы</param> public static void OnTransferCardToCard(object source, TransferEventArgs args) => TransactionList.Add(args.LogMessage);
public void MoveNoChangeSingleItem() { TransactionList tl = new TransactionList(); tl.Add(newTx("2012-02-05")); var tx = tl[0]; var txDate = tx.Date; tl.Move(0, 0); Assert.AreEqual(tx, tl[0]); Assert.AreEqual(tx.Date, txDate, "Should not change"); }
static void Main(string[] args) { TransactionList tList = new TransactionList(); TransactionList rList = new TransactionList(); bool finished = false; do { Console.WriteLine("1- Add transaction"); Console.WriteLine("2- Add repetitive transaction"); Console.WriteLine("3- Show transactions in a month"); Console.WriteLine("4- Search by text"); Console.WriteLine("Q- Quit"); switch (Console.ReadLine()[0]) { case '1': // 1- Add transaction Console.WriteLine("Day: "); byte day = Convert.ToByte(Console.ReadLine()); Console.WriteLine("Month: "); byte month = Convert.ToByte(Console.ReadLine()); Console.WriteLine("Year: "); short year = Convert.ToInt16(Console.ReadLine()); Console.WriteLine("Amount: "); double amount = Convert.ToDouble(Console.ReadLine()); Console.WriteLine("Description: "); string description = Console.ReadLine(); tList.Add(new Transaction(day, month, year, amount, description)); break; case '2': // 2- Add repetitive transaction Console.WriteLine("Day: "); byte rday = Convert.ToByte(Console.ReadLine()); Console.WriteLine("Month: "); byte rmonth = Convert.ToByte(Console.ReadLine()); Console.WriteLine("Amount: "); double ramount = Convert.ToDouble(Console.ReadLine()); Console.WriteLine("Description: "); string rdescription = Console.ReadLine(); rList.Add(new RepetitiveTransaction(rday, rmonth, ramount, rdescription)); break; case '3': // 3- Show transactions in a month Console.WriteLine("Month: "); byte sMonth = Convert.ToByte(Console.ReadLine()); Console.WriteLine("Year: "); byte sYear = Convert.ToByte(Console.ReadLine()); for (int i = 0; i < tList.GetLength(); i++) { Transaction t = (Transaction)tList.GetTransaction(i); if (t.Month == sMonth && t.Year == sYear) { Console.WriteLine(tList.GetTransaction(i)); } } for (int i = 0; i < rList.GetLength(); i++) { RepetitiveTransaction t = (RepetitiveTransaction)rList.GetTransaction(i); if (t.Month == sMonth) { Console.WriteLine(rList.GetTransaction(i)); } } break; case '4': Console.WriteLine("Enter text to search: "); string search = Console.ReadLine(); for (int i = 0; i < tList.GetLength(); i++) { if (tList.GetTransaction(i).ToString().Contains(search)) { Console.WriteLine(tList.GetTransaction(i)); } } for (int i = 0; i < rList.GetLength(); i++) { if (rList.GetTransaction(i).ToString().Contains(search)) { Console.WriteLine(rList.GetTransaction(i)); } } break; case 'q': case 'Q': finished = true; break; } } while (!finished); }
public TransactionList GetLatestTransactionsLimit(int latestRecs, int userId) { try { TransactionList transList = new TransactionList(); using (EntityContext context = new EntityContext()) { context.Configuration.LazyLoadingEnabled = true; var query1 = (from i in context.Transaction .Include(i => i.TransactionType) .Include(i => i.TransactionReasonType) .Include(i => i.Category) .Include(i => i.Category.TypeTransactionReasons) .Include(i => i.ModifiedUser) .Include(i => i.CreatedUser) where !i.IsDeleted && i.ModifiedUser.UserId == userId orderby i.TransactionDate descending select i).Take(latestRecs == 0 ? int.MaxValue : latestRecs).ToList(); //investigate if there is a better way to convert the generic list to ObservableCollection foreach (var item in query1) { //item.trans.HasPhotos = item.hasPhotos; item.HasPhotos = context.TransactionImage.Count(x => x.Transaction.TransactionId == item.TransactionId && !x.IsDeleted) > 0; //var trans = item.item; if (item.Category.IsDeleted) { item.Category = context.Category.FirstOrDefault(x => x.Name.Equals("other", StringComparison.InvariantCultureIgnoreCase)); item.TransactionReasonType = context.TransactionReason.FirstOrDefault(x => x.Name.Equals("other", StringComparison.InvariantCultureIgnoreCase)); } if (item.TransactionReasonType.IsDeleted) { item.TransactionReasonType = context.TransactionReason.FirstOrDefault(x => x.Name.Equals("other", StringComparison.InvariantCultureIgnoreCase)); } transList.Add(item); } transList.PrepareForServiceSerialization(); return transList; } } catch (Exception) { throw; } }
public TransactionList GetAllTransactions(int userId) { return null; try { TransactionList transList = new TransactionList(); using (EntityContext context = new EntityContext()) { var query = (from i in context.Transaction .Include(i => i.Category) .Include(i => i.CreatedUser) .Include(i => i.ModifiedUser) .Include(i => i.TransactionReasonType) .Include(i => i.TransactionType) where !i.IsDeleted && i.ModifiedUser.UserId == userId select new { transaction = i, category = i.Category.IsDeleted ? null : i.Category, categoryOther = context.Category.FirstOrDefault(x => x.Name.Equals("other", StringComparison.InvariantCultureIgnoreCase)), transReason = i.TransactionReasonType.IsDeleted ? null : i.TransactionReasonType, transReasonOther = context.TransactionReason.FirstOrDefault(x => x.Name.Equals("other", StringComparison.InvariantCultureIgnoreCase)) }).ToList(); foreach (var item in query) { var trans = item.transaction; if (item.category == null) { trans.Category = item.categoryOther; trans.TransactionReasonType = item.transReasonOther; } if (item.transReason == null) { trans.TransactionReasonType = item.transReasonOther; } transList.Add(trans); } transList.AcceptChanges(); return transList; } } catch (Exception) { throw; } }
internal TransactionList GetItemTransactionList(Station source, Station destination, ItemType type) { TransactionList list = new TransactionList(); Trade[] forSale = source.ItemsForSale[type].ToArray(); Trade[] wanted = destination.ItemsWanted[type].ToArray(); int buyIndex = 0; int sellIndex = 0; int buyAmount = 0; int sellAmount = 0; TransactionItem purchase = null; TransactionItem sale = null; Transaction currentTransaction = null; bool finished = false; int minQtyNeeded = 0; while (!finished) { // Source station has more than destination wants if ((forSale[buyIndex].Quantity - buyAmount) > (wanted[sellIndex].Quantity - sellAmount)) { // Set the amount (qty) of the transaction int amount = (wanted[sellIndex].Quantity - sellAmount); // Create trades purchase = new TransactionItem(forSale[buyIndex], amount); if (minQtyNeeded > 0) { minQtyNeeded -= amount; } else { if (wanted[sellIndex].MinQuantity > amount) { sale = new TransactionItem(wanted[sellIndex]); minQtyNeeded = wanted[sellIndex].MinQuantity - amount; } else { sale = new TransactionItem(wanted[sellIndex], amount); } } // Set the buy amount up by the amount that can be sold buyAmount += amount; // reset the sell amount sellAmount = 0; sellIndex++; } // Source station has less than destination wants else if ((forSale[buyIndex].Quantity - buyAmount) < (wanted[sellIndex].Quantity - sellAmount)) { // Set the amount (qty) of the transaction int amount = (forSale[buyIndex].Quantity - buyAmount); // Create trades purchase = new TransactionItem(forSale[buyIndex], amount); if (minQtyNeeded > 0) { minQtyNeeded -= amount; } else { if (wanted[sellIndex].MinQuantity > amount) { sale = new TransactionItem(wanted[sellIndex]); minQtyNeeded = wanted[sellIndex].MinQuantity - amount; } else { sale = new TransactionItem(wanted[sellIndex], amount); } } // Set the buy amount up by the amount that can be sold sellAmount += amount; // reset the buy amount buyAmount = 0; buyIndex++; } else { // Set the amount (qty) of the transaction int amount = (wanted[sellIndex].Quantity - sellAmount); // Create trades purchase = new TransactionItem(forSale[buyIndex], amount); if (minQtyNeeded > 0) { minQtyNeeded -= amount; } else { if (wanted[sellIndex].MinQuantity > amount) { sale = new TransactionItem(wanted[sellIndex]); minQtyNeeded = wanted[sellIndex].MinQuantity - amount; } else { sale = new TransactionItem(wanted[sellIndex], amount); } } // Reset both buy and sell amount buyAmount = 0; sellAmount = 0; buyIndex++; sellIndex++; } if (currentTransaction == null) { currentTransaction = new Transaction(purchase, sale); } else { currentTransaction.AddPurchase(purchase); if (sale != null) { currentTransaction.AddSale(sale); } } purchase = null; sale = null; if ((wanted.Length <= sellIndex) || (forSale.Length <= buyIndex) || (wanted[sellIndex].UnitPrice <= forSale[buyIndex].UnitPrice)) { finished = true; } // If minimum quantity is achieved, add the transaction if ((finished) || ((minQtyNeeded <= 0) && (!((wanted[sellIndex].UnitPrice == wanted[Math.Max(sellIndex-1, 0)].UnitPrice) && (forSale[buyIndex].UnitPrice == forSale[Math.Max(buyIndex-1, 0)].UnitPrice))) )) { if (currentTransaction.Profit >= 0.0f) { list.Add(currentTransaction); } currentTransaction = null; minQtyNeeded = 0; } } return list; }
public void MoveDownToBottom() { TransactionList tl = new TransactionList(); tl.Add(newTx("2012-02-05")); tl.Add(newTx("2012-02-10")); tl.Add(newTx("2012-02-15")); var tx = tl[1]; tl.Move(1, 2); Assert.AreEqual(tx, tl[2]); Assert.AreEqual(tx.Date, tl[1].Date, "Should be same as preceding"); }
public void MoveNoChange() { TransactionList tl = new TransactionList(); tl.Add(newTx("2012-02-05")); tl.Add(newTx("2012-02-10")); tl.Add(newTx("2012-02-15")); var tx = tl[1]; var txDate = tx.Date; tl.Move(1, 1); Assert.AreEqual(tx, tl[1]); Assert.AreEqual(tx.Date, txDate, "Should not change"); }
public void AddTransaction(ITransaction transaction) { TransactionList.Add(transaction); TransactionList.Sort((x, y) => x.Timestamp.CompareTo(y.Timestamp)); }
public void AddTransaction() { string text; Console.WriteLine(); do { Console.Write("Enter the year of the transaction: "); text = Console.ReadLine(); if (!IsValidNumber(text)) { Console.WriteLine("Year not valid."); } }while (!IsValidNumber(text)); ushort year = Convert.ToUInt16(text); do { Console.Write("Enter the month of the transaction: "); text = Console.ReadLine(); if (!IsValidMonth(text)) { Console.WriteLine("Month not valid."); } }while (!IsValidMonth(text)); byte month = Convert.ToByte(text); do { Console.Write("Enter the day of the transaction: "); text = Console.ReadLine(); if (!IsValidDay(text, month)) { Console.WriteLine("Day not valid."); } }while (!IsValidDay(text, month)); byte day = Convert.ToByte(text); do { Console.Write("Enter the amount of the transaction: "); text = Console.ReadLine(); if (!IsValidNumber(text)) { Console.WriteLine("Not valid amount."); } }while (!IsValidNumber(text)); double amount = Convert.ToDouble(text); string description; do { Console.Write("Enter the description of the transaction: "); description = Console.ReadLine(); if (description == "") { Console.WriteLine("Description should not be empty."); } }while (description == ""); transactionList.Add( new Transaction(day, month, year, amount, description)); }
public TransactionList GetTransactionsForBudget(int budgetId) { try { TransactionList transactionList = new TransactionList(); using (EntityContext context = new EntityContext()) { // DateTime d = DateTime.Now.AddDays(100); var query = from i in context.Transaction .Include(i => i.TransactionType).Where(k => !k.IsDeleted) .Include(i => i.TransactionReasonType).Where(k => !k.IsDeleted) .Include(i => i.Category).Where(k => !k.IsDeleted) //.Include(i => i.CreatedUser) //.Include(i => i.ModifiedUser) where i.CreatedDate >= context.Budget.Where(b => b.BudgetId == budgetId).Select(b => b.FromDate).FirstOrDefault() && i.CreatedDate <= context.Budget.Where(b => b.BudgetId == budgetId).Select(b => b.ToDate).FirstOrDefault() && !i.IsDeleted orderby i.CreatedDate descending select i; foreach (var item in query) transactionList.Add(item); transactionList.AcceptChanges(); return transactionList; } } catch (Exception) { throw; } }
private void GetTransactionsForBudgets(BudgetList budgetList) { try { using (EntityContext context = new EntityContext()) { foreach (var item in budgetList) { var inQuery = from t in context.Transaction .Include(t => t.TransactionType).Where(k => !k.IsDeleted) where t.TransactionDate >= item.FromDate && t.TransactionDate <= item.ToDate && !t.IsDeleted && t.ModifiedUser.UserId == item.ModifiedUser.UserId select t; TransactionList tl = new TransactionList(); foreach (var inItem in inQuery.ToList()) tl.Add(inItem); item.Transactions = tl; ////Apply the rule to create a new budget if the expired one is set to Repeat //if (item.Repeat && item.ToDate < DateTime.Now) //{ // var dataSpanRange = item.ToDate - item.FromDate; // var dataSpanToday = DateTime.Now - item.ToDate; // var dateDif = dataSpanRange.Days; // var diff = dataSpanToday.Days % dataSpanRange.Days; // var newFromDate = DateTime.Now.AddDays(-diff + 1); // var newToDate = newFromDate.AddDays(dataSpanRange.Days); // var test = newToDate - newFromDate; // var newBudget = item.Clone(); // newBudget.FromDate = newFromDate; // newBudget.ToDate = newToDate; // item.Repeat = false; // context.Budget.Add(newBudget); // //context.SaveChanges(); //} } //return budgetList; } } catch (Exception) { throw; } }
public void MoveUpToTop() { TransactionList tl = new TransactionList(); tl.Add(newTx("2012-02-05")); tl.Add(newTx("2012-02-10")); tl.Add(newTx("2012-02-15")); var tx = tl[1]; tl.Move(1, 0); Assert.AreEqual(tx, tl[0]); Assert.AreEqual(tx.Date, tl[1].Date, "Should be same as following"); }