public void AddTaskwithParent() { TaskManagerController controller = new TaskManagerController(); controller.Request = new HttpRequestMessage(); controller.Configuration = new HttpConfiguration(); string locationUrl = "http://localhost:55396/api/AddTaskwithParent"; // Create the mock and set up the Link method, which is used to create the Location header. // The mock version returns a fixed string. var mockUrlHelper = new Mock <UrlHelper>(); mockUrlHelper.Setup(x => x.Link(It.IsAny <string>(), It.IsAny <object>())).Returns(locationUrl); controller.Url = mockUrlHelper.Object; // Act TaskandParent t = new TaskandParent(); t.task = "Task" + DateTime.Now.ToLongDateString() + DateTime.Now.ToLongTimeString(); t.isparent = 1; //t.priority = 10; //t.parent_id = 1; t.start_date = null; t.end_date = null; var response = controller.AddTaskwithParent(t); Trace.Write(response); // Assert //Assert.AreEqual(locationUrl, response.Headers.Location.AbsoluteUri); }
public int AddTaskwithParent([FromBody] TaskandParent tp) { Tasks tasks = new Tasks(); tasks.task = tp.task; tasks.parent_id = tp.parent_id; tasks.priority = tp.priority; tasks.start_date = tp.start_date; tasks.end_date = tp.end_date; return(bl.AddTaskwithParent(tasks)); }
public int AddTaskwithParent([FromBody] TaskandParent tp) { Tasks tasks = new Tasks(); tasks.task = tp.task; tasks.parent_id = tp.parent_id; tasks.priority = tp.priority; if (tp.project_id != 0) { tasks.project_id = tp.project_id; } else { tasks.project_id = null; } tasks.start_date = tp.start_date; tasks.end_date = tp.end_date; return(bl.AddTaskwithParent(tasks, tp.isparent, tp.user_id)); }