public void AddTaskList() { ListBox taskListBox = Application.OpenForms["frmMain"].Controls["taskList"] as ListBox; TextBox nameBox = Application.OpenForms["frmMain"].Controls["TaskListName"] as TextBox; if (nameBox.Text == "") { MessageBox.Show("Write a name of Task List"); } else { TaskList taskList = new TaskList { Name = nameBox.Text, User = _securityManager.GetLoggedUser() }; try { _taskListManager.CreateTaskList(taskList); } catch (TaskListException e) { MessageBox.Show(e.Message); } ShowTaskList(); } }
public NoteTest() { IoC.Configure(); _user = new User(); IUserManager um = ObjectFactory.GetInstance<IUserManager>(); um.CreateUser(_user); _taskList = new TaskList() { Name = "new list", Creator = _user, Users = new List<User>() { _user } }; _taskListManager = ObjectFactory.GetInstance<ITaskListManager>(); _taskListManager.CreateTaskList(_user, _taskList); _noteManager = ObjectFactory.GetInstance<INoteManager>(); }
public IHttpActionResult PostNewTaskList(string name) { User user = _securityManager.GetLoggedUser(); TaskList taskList = new TaskList { Name = name, User = user }; try { _taskListManager.CreateTaskList(taskList); return(Ok("Task List " + name + " created")); } catch (TaskListException e) { return(ResponseMessage(Request.CreateErrorResponse(HttpStatusCode.NotFound, e.Message))); } }
public ActionResult CreateTaskList(string name) { User user = _securityManager.GetLoggedUser(); TaskList taskList = new TaskList { Name = name, User = user }; try { _taskListManager.CreateTaskList(taskList); TempData["ConfirmationMessage"] = "Task List created successfully"; return(RedirectToAction("CreateTaskListView", "TaskList")); } catch (TaskListException e) { ModelState.AddModelError("", e.Message); TempData["ConfirmationMessage"] = "Task List not created"; return(RedirectToAction("CreateTaskListView", "TaskList")); } //string apiUrl = "http://localhost:51004/Tasklists/Add/"; //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> { { "name", Name } }; // var encodedContent = new FormUrlEncodedContent(parameters); // var postTask = client.PostAsJsonAsync(apiUrl + Name, parameters); // postTask.Wait(); // var result = postTask.Result; // if (result.IsSuccessStatusCode) // { // return RedirectToAction("CreateTaskListView", "TaskList"); // } // return RedirectToAction("CreateTaskListView", "TaskList"); //} }
public void CreateTaskList() { Console.WriteLine("Write a name for your Task List"); string name = Console.ReadLine(); TaskList taskList = new TaskList { Name = name, User = _securityManager.GetLoggedUser(), }; try { _taskListManager.CreateTaskList(taskList); Console.WriteLine("Done"); } catch { Console.WriteLine("Task List not created, you did something wrong"); } System.Threading.Thread.Sleep(1000); ListTaskLists(); }