Ejemplo n.º 1
0
        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);
            //    }
            //}
        }
Ejemplo n.º 2
0
        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();
        }
Ejemplo n.º 3
0
        public void UpdateTaskList(int id)
        {
            ListBox taskListBox = Application.OpenForms["frmMain"].Controls["taskList"] as ListBox;
            TextBox nameBox     = Application.OpenForms["frmMain"].Controls["TaskListNewName"] as TextBox;

            int?     userid   = _securityManager.GetLoggedUserId();
            TaskList taskList = _taskListManager.GetTaskList(id);

            taskList.Name = nameBox.Text;
            _taskListManager.UpdateTaskList(taskList);
            ShowTaskList();
        }
Ejemplo n.º 4
0
 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)));
     }
 }
Ejemplo n.º 5
0
 public IHttpActionResult GetTaskList(int taskListId)
 {
     try
     {
         var taskList = _taskListManager.GetTaskList(taskListId);
         return(Ok(taskList));
     }
     catch (TaskListNotFoundException e)
     {
         return(ResponseMessage(Request.CreateErrorResponse(HttpStatusCode.NotFound, e.Message)));
     }
 }
Ejemplo n.º 6
0
        //  [HttpDelete] //not working with
        public ActionResult DeleteTaskList(int id)
        {
            User     user     = _securityManager.GetLoggedUser();
            TaskList taskList = _taskListManager.GetTaskList(id);

            try
            {
                _taskListManager.DeleteTaskList(taskList);
                TempData["ConfirmationMessage"] = "Task List deleted successfully";
                return(RedirectToAction("GetTaskLists", "TaskList", new { currentPageIndex = 1 }));
            }
            catch (TaskListException e)
            {
                ModelState.AddModelError("", e.Message);
                TempData["ConfirmationMessage"] = "Task List not deleted";
                return(RedirectToAction("GetTaskLists", "TaskList", new { currentPageIndex = 1 }));
            }


            //string apiUrl = "http://localhost:51004/Tasklists/Delete/";

            //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"));

            //    var deleteTask = client.DeleteAsync(apiUrl + Id);

            //    deleteTask.Wait();
            //    var result = deleteTask.Result;
            //    if (result.IsSuccessStatusCode)
            //    {
            //        return RedirectToAction("GetTaskLists", "TaskList");
            //    }

            //    return RedirectToAction("GetTaskLists", "TaskList");
            //}
        }
Ejemplo n.º 7
0
 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();
     }
 }