public Result <IList <Expenses> > GetAll(int plannerId) { var result = new Result <IList <Expenses> >(); ExpensesService ExpensesService = new ExpensesService(); result.Value = ExpensesService.GetAll(plannerId); result.IsSuccess = true; return(result); }
public void GetAllShouldReturnCorrectNumberOfPagesForExpenses() { var options = new DbContextOptionsBuilder <ExpensesDbContext>() .UseInMemoryDatabase(databaseName: nameof(GetAllShouldReturnCorrectNumberOfPagesForExpenses)) .Options; using (var context = new ExpensesDbContext(options)) { var expenseService = new ExpensesService(context); var added = expenseService.Create(new Lab6.Viewmodels.ExpensePostModel { Description = "Variable", Type = "5", Location = "Sibiu", Date = Convert.ToDateTime("2019-05-05T11:11:11"), Currency = "USD", Sum = 555.77, Comments = new List <Comment>() { new Comment { Important = true, Text = "Very important expense", Owner = null } }, }, null); DateTime from = DateTime.Parse("2019-04-13T00:00:00"); DateTime to = DateTime.Parse("2019-06-19T00:00:00"); var allExpenses = expenseService.GetAll(1, from, to); Assert.AreEqual(1, allExpenses.Entries.Count); Assert.IsNotNull(allExpenses); } }
// GET: Expenses public async Task <ActionResult> Index() { var expenses = await _service.GetAll(); return(View(expenses)); }