Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions MoneyNote/Controllers/AccountController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,15 @@ public class AccountController : Controller
// GET: 回傳帳簿資料
public ActionResult Index()
{
FakeAccountData AccountBooks = new FakeAccountData();

return View(AccountBooks.GetFakeAccountData());

return View();
}
[ChildActionOnly]
public ActionResult AccountItems()
{
FakeAccountData AccountBooks = new FakeAccountData();
FakeAccountData accountBooks = new FakeAccountData();

return View(AccountBooks.GetFakeAccountData());
return View(accountBooks.GetFakeAccountData());
}
}
}
31 changes: 13 additions & 18 deletions MoneyNote/Models/FakeAccountData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,29 +9,24 @@ namespace MoneyNote.Models
public class FakeAccountData
{
/// <summary>
/// 記憶體暫存記帳本
/// Gets the fake account data.
/// </summary>
private static List<AccountViewModel> MyAccountBooks;

public List<AccountViewModel> GetFakeAccountData()
/// <returns></returns>
public IEnumerable<AccountViewModel> GetFakeAccountData()
{
MyAccountBooks = new List<AccountViewModel>();

//收入的sample資料
for (int i = 1; i < 51; i++)
for (var i = 1; i < 51; i++)
{
if (i <= 25)

MyAccountBooks.Add(new AccountViewModel { Id = i, Category = "收入", Amoount = i * 1000, UpdateDate = DateTime.Now.AddDays(i), Remarks = "收入" + i });
else
MyAccountBooks.Add(new AccountViewModel { Id = i, Category = "支出", Amoount = i * 500, UpdateDate = DateTime.Now.AddDays(i), Remarks = "支出" + i });

var type = i < 25 ? "收入" : "支出";
yield return new AccountViewModel
{
Id = i,
Category = type,
Amoount = i * i < 25 ? 1000 : 500,
UpdateDate = DateTime.Now.AddDays(i),
Remarks = type + i
};
}


return MyAccountBooks;

}

}
}