예제 #1
0
        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);
        }
예제 #2
0
 public void UpdateTask(int id, TaskTableData taskData)
 {
     if (TableTaskExists(id))
     {
         tmContext.Entry(taskData).State = EntityState.Modified;
         tmContext.SaveChanges();
     }
 }
예제 #3
0
        public void DeleteTask(int id)
        {
            TaskTableData tableTask = tmContext.TaskTableData.Find(id);

            if (tableTask != null)
            {
                tmContext.TaskTableData.Remove(tableTask);
                tmContext.SaveChanges();
            }
        }
예제 #4
0
 // 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));
     }
 }
예제 #5
0
        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);
        }
예제 #6
0
 public void AddTask(TaskTableData taskData)
 {
     tmContext.TaskTableData.Add(taskData);
     tmContext.SaveChanges();
 }
예제 #7
0
 public void UpdateTask(int id, TaskTableData taskData)
 {
     tmDL.UpdateTask(id, taskData);
 }
예제 #8
0
 public void AddTask(TaskTableData taskData)
 {
     tmDL.AddTask(taskData);
 }