public IHttpActionResult editParentTask([FromBody] ParentTaskModel parentTask) { if (!ModelState.IsValid) { return(BadRequest("Not a valid data")); } try { if (parentTask != null)//if 0 for no chnage in parent task { TaskManagerRepository tmRep = new TaskManagerRepository(); Parent_Task_Tbl parentTaskDb = new Parent_Task_Tbl { Parent_ID = parentTask.ParentTaskID, Parent_Task = parentTask.ParentTaskName, }; string result = "{'ParentTaskID': " + tmRep.EditParentTask(parentTaskDb) + "}"; JObject json = JObject.Parse(result); return(Ok <JObject>(json)); } else { return(BadRequest("Error occurred in editProject")); } } catch (Exception ex) { return(BadRequest("Error occurred in EditParentTask :" + ex.StackTrace)); } }
public IHttpActionResult ManageParentTask([FromBody] ParentTaskModel parentTask) { if (!ModelState.IsValid) { return(BadRequest("Not a valid data")); } try { TaskManagerRepository parentTaskRep = new TaskManagerRepository(); Parent_Task_Tbl parentTaskDb = parentTaskRep.getParent(parentTask.ParentTaskID); if (parentTaskDb != null) { parentTaskDb.Parent_Task = parentTask.ParentTaskName; string result = "{'ParentTaskID': " + parentTaskRep.EditParentTask(parentTaskDb) + "}"; JObject json = JObject.Parse(result); return(Ok <JObject>(json)); } else { Parent_Task_Tbl parentTaskNewDb = new Parent_Task_Tbl { Parent_Task = parentTask.ParentTaskName, }; string result = "{'ParentTaskID': " + parentTaskRep.CreateParentTask(parentTaskNewDb) + "}"; JObject json = JObject.Parse(result); return(Ok <JObject>(json)); } } catch (Exception ex) { return(BadRequest("Error occurred in CreateParentTask :" + ex.StackTrace)); } }