-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtaskListController.cs
More file actions
134 lines (94 loc) · 3.22 KB
/
Copy pathtaskListController.cs
File metadata and controls
134 lines (94 loc) · 3.22 KB
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using Google.Apis.Tasks.v1;
using Google.Apis.Tasks.v1.Data;
using System.Web.Http;
using WebApplication4.Models;
namespace WebApplication4.Controllers
{
public class taskListController : ApiController
{
Authorization auth = new Authorization();
[HttpGet]
[Route("api/TaskListAll")]
public List<MyTaskList> GetTaskList()
{
var response = auth.service.Tasklists.List();
var result = response.Execute();
var items = result.Items;
if (items != null && items.Count > 0)
{
List<MyTaskList> myLists = new List<MyTaskList>();
foreach (var i in items)
{
MyTaskList a = new MyTaskList();
a.Id = i.Id;
a.title = i.Title;
myLists.Add(a);
}
return myLists;
}
else
{
return null;
}
}
// the followoing function will be used as per requirement.
//function insert tasklist change into post
[HttpPost]
[Route("api/taskList/insert")]
public string InsertTaskList([FromBody]MyTaskList _list)
{
TaskList list = new TaskList { Title = _list.title};
var response = auth.service.Tasklists.Insert(list);
var result = response.Execute();
var items = result.Id;
return "Your Task is successfull inserted ";
}
// delete function will be change httpDelete
[HttpGet]
[Route("api/taskList/delete/{id}")]
public string deletetasklist(string id)
{
var response = auth.service.Tasklists.Delete(id);
var result = response.Execute();
return "successful Deleted TaskList";
}
//Api for routing Page
[HttpGet]
[Route("api/taskList/{id}")]
public MyTaskList SingleTaskList(string id)
{
var response = auth.service.Tasklists.Get(id);
var result = response.Execute();
MyTaskList list = new MyTaskList();
list.title = result.Title;
list.Id = result.Id;
return list;
}
// get/show function of single tasklist
[HttpGet]
[Route("api/defaultTasklist")]
public List<MyTaskListGet> GetTaskListShow()
{
List<MyTaskListGet> myList = new List<MyTaskListGet>();
var response = auth.service.Tasklists.Get("@default");
if (response.Tasklist != "@default")
{
TaskList list = new TaskList { Title = "Default" };
var response2 = auth.service.Tasklists.Insert(list);
response2.Execute();
}
response = auth.service.Tasklists.Get("@default");
var result = response.Execute();
MyTaskListGet a = new MyTaskListGet();
a.id = result.Id;
a.title = result.Title;
myList.Add(a);
return myList;
}
}
}