public void UpdateTaskList()
        {
            Console.WriteLine("Write an ID of Task List you want to update");
            int id = Int32.Parse(Console.ReadLine());

            Console.WriteLine("Write a new name for your Task List");
            string name = Console.ReadLine();

            TaskList taskList = new TaskList
            {
                Id   = id,
                Name = name,
            };

            try
            {
                _taskListManager.UpdateTaskList(taskList);
                Console.WriteLine("Done");
            }
            catch
            {
                Console.WriteLine("Task List not updated, you did something wrong");
            }
            System.Threading.Thread.Sleep(1000);

            ListTaskLists();
        }
        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();
        }
示例#3
0
        public IHttpActionResult PutTaskList(int id, string name)
        {
            User     user     = _securityManager.GetLoggedUser();
            TaskList taskList = new TaskList {
                Id = id, Name = name, User = user
            };

            try
            {
                _taskListManager.UpdateTaskList(taskList);
                return(Ok("Task List Id: " + id + " New name: " + name + " updated"));
            }
            catch (TaskListNotFoundException e)
            {
                return(ResponseMessage(Request.CreateErrorResponse(HttpStatusCode.NotFound, e.Message)));
            }
        }
        public ActionResult EditTaskList(int id, string name)
        {
            TaskList taskList = _taskListManager.GetTaskList(id);

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

            //TaskList taskList = null;
            //string Id = id.ToString();
            //string apiUrl = "http://localhost:51004/Tasklists/Update/";

            //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 parameters = new Dictionary<string, string> { { "id", Id }, { "name", name } };
            //      var encodedContent = new FormUrlEncodedContent(parameters);

            //    var putTask = client.PutAsJsonAsync(apiUrl + Id + "/" + name, parameters);

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

            //    return View(taskList);
            //}
        }