Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public bool Uncomplete()
- {
- bool AnyLeft = false;
- var tasks = from t in db.Tasks orderby t.EntryDate descending select t;
- foreach (Task match in tasks)
- {
- if (match.IsCompleted == false)
- {
- AnyLeft = true;
- }
- }
- return AnyLeft;
- }
- public ActionResult Index()
- {
- bool AnyLeft = Uncomplete();
- var tasks = from t in db.Tasks orderby t.EntryDate descending select t;
- return View(tasks.ToList());
- }
- <% if (AnyLeft == false)
- { %>
- <h1 class="green">My Tasks</h1>
- <% }
- else
- { %>
- <h1 class="red">My Tasks</h1>
- <% } %>
- return View(tasks.ToList(), AnyLeft);
- public ActionResult Index()
- {
- ViewData["AnyLeft"] = Uncomplete();
- var tasks = from t in db.Tasks orderby t.EntryDate descending select t;
- return View(tasks.ToList());
- }
- <% if (!(bool)ViewData["AnyLeft"])
- { %>
- <h1 class="green">My Tasks</h1>
- <% }
- else
- { %>
- <h1 class="red">My Tasks</h1>
- <% } %>
- public static class TaskExtensions {
- public static bool Uncomplete(this IEnumerable<Task> tasks) {
- return (from t in tasks where !t.IsCompleted select t).Any();
- }
- }
- <h1 class="<%= (tasks.Uncomplete()) ? "Red" : "Green" %>">My Tasks</h1>
- public bool Uncomplete()
- {
- bool AnyLeft = false;
- var tasks = from t in db.Tasks
- where !t.IsCompleted // or you could use t.IsCompleted == false
- orderby t.EntryDate descending select t;
- AnyLeft = tasks.Any;
- return AnyLeft;
- }
- foreach (Task match in tasks)
- {
- if (!match.IsCompleted)
- {
- AnyLeft = true;
- break;
- }
- }
Add Comment
Please, Sign In to add comment