public void TestMethodGetTask() { TaskController tmController = new TaskController() { Request = new HttpRequestMessage(), Configuration = new HttpConfiguration() }; TaskTableData taskData = new TaskTableData() { Task_ID = 1, Parent_ID = 0, Task = "Task2", Start_Date = DateTime.Now, End_Date = DateTime.Now.AddDays(5), Priority = 15, Status = true }; string ExpectedResult = "OK"; HttpResponseMessage actualResponse = tmController.Get(1); string ActualResult = actualResponse.StatusCode.ToString(); Assert.AreEqual(ExpectedResult, ActualResult); TaskTableData responseData; actualResponse.TryGetContentValue(out responseData); Assert.AreEqual(taskData.Task, responseData.Task); }
public void UpdateTask(int id, TaskTableData taskData) { if (TableTaskExists(id)) { tmContext.Entry(taskData).State = EntityState.Modified; tmContext.SaveChanges(); } }
public void DeleteTask(int id) { TaskTableData tableTask = tmContext.TaskTableData.Find(id); if (tableTask != null) { tmContext.TaskTableData.Remove(tableTask); tmContext.SaveChanges(); } }
// PUT api/<controller>/5 public HttpResponseMessage Put(int id, [FromBody] TaskTableData taskData) { try { tmBL.UpdateTask(id, taskData); return(Request.CreateResponse(HttpStatusCode.OK, "success")); } catch (Exception ex) { return(Request.CreateResponse(HttpStatusCode.InternalServerError, ex)); } }
public void TestMethodUpdateTask() { TaskController tmController = new TaskController() { Request = new HttpRequestMessage(), Configuration = new HttpConfiguration() }; TaskTableData taskData = new TaskTableData() { Task_ID = 3, Parent_ID = 0, Task = "Task3", Start_Date = DateTime.Now, End_Date = DateTime.Now.AddDays(5), Priority = 15, Status = true }; string ExpectedResult = "OK"; HttpResponseMessage actualResponse = tmController.Put(3, taskData); string ActualResult = actualResponse.StatusCode.ToString(); Assert.AreEqual(ExpectedResult, ActualResult); }
public void AddTask(TaskTableData taskData) { tmContext.TaskTableData.Add(taskData); tmContext.SaveChanges(); }
public void UpdateTask(int id, TaskTableData taskData) { tmDL.UpdateTask(id, taskData); }
public void AddTask(TaskTableData taskData) { tmDL.AddTask(taskData); }