//// PUT api/values/5 //[HttpPut] //public IHttpActionResult EditTask([FromBody]TaskModel TaskModel) //{ // if (!ModelState.IsValid) // return BadRequest("Not a valid data"); // try // { // return TaskDBChanges(TaskModel); // } // catch (Exception ex) // { // return BadRequest("Error occurred in EditTask :" + ex.StackTrace); // } //} private IHttpActionResult TaskDBChanges(TaskModel taskModel, int parentID = 0) { TaskManagerRepository taskRep = new TaskManagerRepository(); Task_Tbl taskDb = taskRep.GetTaskRepo(taskModel.TaskId); if (taskDb != null) { taskDb.Parent_ID = parentID > 0 ? parentID : (int?)null; taskDb.Task = taskModel.TaskName; taskDb.Start_Date = Convert.ToDateTime(taskModel.StartDate); taskDb.End_Date = Convert.ToDateTime(taskModel.EndDate); taskDb.Priority = taskModel.Priority; taskDb.Is_Completed = Convert.ToBoolean(taskModel.IsCompleted); string result = "{'TaskID': " + taskRep.EditTask(taskDb) + "}"; JObject json = JObject.Parse(result); return(Ok <JObject>(json)); } else { Task_Tbl taskDbNew = new Task_Tbl { Task = taskModel.TaskName, Start_Date = Convert.ToDateTime(taskModel.StartDate), End_Date = Convert.ToDateTime(taskModel.EndDate), Priority = taskModel.Priority }; string result = "{'TaskID': " + taskRep.CreateTask(taskDbNew) + "}"; JObject json = JObject.Parse(result); return(Ok <JObject>(json)); } }