-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTodo.cs
62 lines (51 loc) · 1.61 KB
/
Todo.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
using Microsoft.WindowsAzure.Storage.Table;
using System;
namespace AzureFunctionsTodo
{
public class Todo
{
public string Id { get; set; } = Guid.NewGuid().ToString("n");
public DateTime CreatedTime { get; set; } = DateTime.UtcNow;
public string TaskDescription { get; set; }
public bool IsCompleted { get; set; }
}
public class TodoCreateModel
{
public string TaskDescription { get; set; }
}
public class TodoUpdateModel
{
public string TaskDescription { get; set; }
public bool IsCompleted { get; set; }
}
public class TodoTableEntity : TableEntity
{
public DateTime CreatedTime { get; set; }
public string TaskDescription { get; set; }
public bool IsCompleted { get; set; }
}
public static class Mappings
{
public static TodoTableEntity ToTableEntity(this Todo todo)
{
return new TodoTableEntity()
{
PartitionKey = "TODO",
RowKey = todo.Id,
CreatedTime = todo.CreatedTime,
IsCompleted = todo.IsCompleted,
TaskDescription = todo.TaskDescription
};
}
public static Todo ToTodo(this TodoTableEntity todo)
{
return new Todo()
{
Id = todo.RowKey,
CreatedTime = todo.CreatedTime,
IsCompleted = todo.IsCompleted,
TaskDescription = todo.TaskDescription
};
}
}
}