-
Notifications
You must be signed in to change notification settings - Fork 0
/
Task.cs
43 lines (38 loc) · 1.13 KB
/
Task.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
using System;
using System.Collections.Generic;
using System.Text.Json;
namespace Tasks
{
public struct Task
{
public string _id { get; set; }
public string body { get; set; }
public bool isCompleted { get; set; }
public bool isDeleted { get; set; }
public static Task JsonToTask(string jsonString)
{
return JsonSerializer.Deserialize<Task>(jsonString);
}
public Task(string body, bool isCompleted)
{
this._id = Guid.NewGuid().ToString();
this.body = body;
this.isCompleted = isCompleted;
this.isDeleted = false;
}
public override string ToString()
{
return $"Task _id: {_id}, body: {body}, isCompleted: {isCompleted}, isDeleted: {isDeleted}";
}
public Dictionary<string, object> ToDictionary()
{
return new Dictionary<string, object>
{
{ "_id", _id },
{ "body", body },
{ "isCompleted", isCompleted },
{ "isDeleted", isDeleted },
};
}
}
}