Hey guys!
I hope all is well. I've been working on my first Windows Phone 8 app in my spare time. It is basically a Task/Todo app that consists of Task Lists that contain multiple Tasks. I can sort the Task Lists off the title and that is no issue, the issue comes when I want to sort the Tasks by Due Date.
The due date it stored at Google (Google Tasks) as: 10/01/2012 00:00:00 and when I pull it into my UI I parse it like:
And that works great. Here is what the function looks like without sorting:
Below is what is I have now - it returns errors when the x.due is null.
I have also tried the below and it doesn't like the ??
Should I be doing this sort somewhere else or is there a way I can capture the null and return MinValue/MaxValue?
- Matt
"If I must boast, I will boast of the things that show my weakness
I hope all is well. I've been working on my first Windows Phone 8 app in my spare time. It is basically a Task/Todo app that consists of Task Lists that contain multiple Tasks. I can sort the Task Lists off the title and that is no issue, the issue comes when I want to sort the Tasks by Due Date.
The due date it stored at Google (Google Tasks) as: 10/01/2012 00:00:00 and when I pull it into my UI I parse it like:
Code:
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
var formatString = value as string;
if (!string.IsNullOrEmpty(formatString))
{
return DateTime.Parse(formatString).Date.ToShortDateString();
}
return "No Due Date";
}
And that works great. Here is what the function looks like without sorting:
Code:
try
{
DateTime dateValue;
var o = JObject.Parse(response.Content);
var lists = new List<TaskItem>();
if (o != null && o["items"] != null)
{
lists =
o["items"].Select(
m => new TaskItem((string)m.SelectToken("id"),
(string)m.SelectToken("kind"),
((string)m.SelectToken("title")) ==
String.Empty
? "Empty"
: (string)
m.SelectToken("title"),
(string)m.SelectToken("notes"),
(string)m.SelectToken("parent"),
(string)
m.SelectToken("position"),
(string)m.SelectToken("update"),
(string)m.SelectToken("due"),
(string)m.SelectToken("deleted"),
(string)m.SelectToken("hidden"),
(string)m.SelectToken("status"),
(string)
m.SelectToken("selfLink"),
(string)
m.SelectToken("completed")
[COLOR=#73D216])).ToList();[/color]
}
var tasks = new List<TaskItem>();
tasks.Clear();
tasks.AddRange(lists);
var list = obj[1] as Action<List<TaskItem>>;
if (list != null) list(tasks);
}
Below is what is I have now - it returns errors when the x.due is null.
Code:
[COLOR=#EF2929])).OrderByDescending(x=>DateTime.Parse(x.due)).ToList();[/color]
I have also tried the below and it doesn't like the ??
Code:
[COLOR=#EF2929])).OrderByDescending(x=>DateTime.Parse(x.due) ?? DateTime.MinValue)).ToList();[/color]
Should I be doing this sort somewhere else or is there a way I can capture the null and return MinValue/MaxValue?
- Matt
"If I must boast, I will boast of the things that show my weakness