private MockExpense CreateMockExp() { string[] listAccm = new string[4] { "Westin Horbour Castle", "Holiday Inn", "Mariot Plaza At Niagra", "Sheraton Suite" }; string[] listFood = new string[4] { "Montana Restaurant", "Kellys Fine Dine", "Starbucks", "Chinese Fine Cusine" }; string[] listTrvl = new string[4] { "Jet Airways", "Air Canada", "British Airways", "US Airways" }; Random rnd = new Random(); int idx = rnd.Next(0, 4); decimal rndAmount = (decimal)Math.Round(rnd.NextDouble() * 500, 2); decimal tax = rndAmount * 0.10M; Random rnd2 = new Random(); int selIdx = rnd2.Next(1, 20); MockExpense mock = new MockExpense(); if (selIdx < 8) { mock.Category = Constants.CategoryAccm; mock.Description = listAccm[idx]; } else if (selIdx < 16) { mock.Category = Constants.CategoryFood; mock.Description = listFood[idx]; } else { mock.Category = Constants.CategoryTrvl; mock.Description = listTrvl[idx]; } mock.Amount = rndAmount; mock.Tax = tax; return(mock); }
// Helper private Transaction[] GetSampleData(string userId, int numOfTrans) { List <Transaction> list = new List <Transaction>(); for (int i = 0; i < numOfTrans; i++) { MockExpense mock = CreateMockExp(); Transaction tran = new Transaction() { UserId = userId, TransType = "DR", Description = mock.Description, Amount = mock.Amount, Tax = mock.Tax, TransDate = DateTime.Now.AddDays(-3), Category = mock.Category, Status = Constants.TransactionStatus.New.ToString() }; list.Add(tran); } return(list.ToArray()); }