public ActionResult GetTaskListItems(int Id) { Session["TaskListId"] = Id.ToString(); TaskList taskList = _taskListManager.GetTaskList(Id); var taskListItems = _taskListManager.ListTaskListItems(taskList); var taskListName = taskList.Name; ViewBag.TaskListName = taskListName; return(View(taskListItems)); // string apiUrl = "http://localhost:51004/TaskList/Tasks/"; //using (HttpClient client = new HttpClient()) //{ // client.BaseAddress = new Uri(apiUrl); // client.DefaultRequestHeaders.Accept.Clear(); // client.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); // HttpResponseMessage response = await client.GetAsync(apiUrl + Id.ToString()); // if (response.IsSuccessStatusCode) // { // var data = await response.Content.ReadAsStringAsync(); // // var table = Newtonsoft.Json.JsonConvert.DeserializeObject<System.Data.DataTable>(data); // List<TaskListItem> taskListItems = Newtonsoft.Json.JsonConvert.DeserializeObject<List<TaskListItem>>(data); // return View(taskListItems); // } //} }
public void ShowTaskListItems(int id) { DataGridView itemsGridView = Application.OpenForms["frmMain"].Controls["ItemsGridView"] as DataGridView; TaskList taskList = _taskListManager.GetTaskList(id); var taskListItems = _taskListManager.ListTaskListItems(taskList); itemsGridView.DataSource = taskListItems; itemsGridView.ClearSelection(); }
public IHttpActionResult GetTasks(int taskListId) //public <-> private { try { var taskList = _taskListManager.GetTaskList(taskListId); try { List <TaskListItem> taskListItems = _taskListManager.ListTaskListItems(taskList); return(Ok(taskListItems)); } catch { return(ResponseMessage(Request.CreateErrorResponse(HttpStatusCode.NotFound, "Tasks not found"))); } } catch (TaskListNotFoundException e) { return(ResponseMessage(Request.CreateErrorResponse(HttpStatusCode.NotFound, e.Message))); } }
public void ListTaskListItems() { try { TaskList taskList = _taskListManager.GetTaskList(ACTUAL_TASK_LIST_ID); List <TaskListItem> listTaskListItems = _taskListManager.ListTaskListItems(taskList); Console.Clear(); Console.WriteLine("Listing available Task List Items: "); Console.WriteLine(""); foreach (var row in listTaskListItems) { Console.WriteLine(row.Id + " " + row.Text + " " + row.IsCompleted); } Console.WriteLine("Done"); MenuOption.TaskMenu(); } catch { Console.WriteLine("There is no such a Task List"); System.Threading.Thread.Sleep(1000); Console.Clear(); _consoleTaskList.ListTaskLists(); } }