public IHttpActionResult CreateParentTask([FromBody] ParentTaskModel parentTask) { if (!ModelState.IsValid) { return(BadRequest("Not a valid data")); } try { TaskManagerRepository parentTaskRep = new TaskManagerRepository(); Parent_Task_Tbl parentTaskDb = new Parent_Task_Tbl { Parent_Task = parentTask.ParentTaskName, }; string result = "{'ParentTaskID': " + parentTaskRep.CreateParentTask(parentTaskDb) + "}"; JObject json = JObject.Parse(result); return(Ok <JObject>(json)); } catch (Exception ex) { return(BadRequest("Error occurred in CreateParentTask :" + ex.StackTrace)); } }
//[HttpGet] //public ParentTaskModel GetParentTask(int parentID) //{ // TaskManagerRepository parentTaskRep = new TaskManagerRepository(); // return _modelFactory.GetParentTaskMoDel(parentTaskRep.GetParentTaskRepo(parentID)); //} //[HttpGet] //public IEnumerable<TaskModel> GetAllTask() //{ // TaskManagerRepository parentTaskRep = new TaskManagerRepository(); // return parentTaskRep.GetAllTaskRepo().ToList().Select(t => _modelFactory.GetTaskModel(t)); //} //[HttpGet] //public TaskModel GetTask(int taskID) //{ // TaskManagerRepository parentTaskRep = new TaskManagerRepository(); // return _modelFactory.GetTaskModel(parentTaskRep.GetTaskRepo(taskID)); //} public int CreateParentTask([FromBody] ParentTaskModel parentTask) { try { TaskManagerRepository parentTaskRep = new TaskManagerRepository(); Parent_Task_Tbl parentTaskDb = new Parent_Task_Tbl { Parent_Task = parentTask.ParentTaskName, }; return(parentTaskRep.CreateParentTask(parentTaskDb)); } catch (Exception ex) { return(0); } }