コード例 #1
0
        public TaskModel GetTask([FromUri] int taskID)
        {
            TaskManagerRepository tmRep = new TaskManagerRepository();
            Task_Tbl taskDb             = tmRep.GetTaskRepo(taskID);

            return(_modelFactory.getTaskModel(taskDb));
        }
コード例 #2
0
        public IHttpActionResult EditEndTask([FromBody] TaskModel taskModel)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest("Not a valid data"));
            }
            try
            {
                TaskManagerRepository taskRep = new TaskManagerRepository();

                Task_Tbl taskDb = taskRep.GetTaskRepo(taskModel.TaskId);

                if (taskDb != null)
                {
                    string  result = "{'TaskID': " + taskRep.EditEndTask(taskModel.TaskId, taskModel.IsCompleted) + "}";
                    JObject json   = JObject.Parse(result);
                    return(Ok <JObject>(json));
                }
                else
                {
                    return(BadRequest("Error occurred during data update in EditEndTask"));
                }
            }
            catch (Exception ex)
            {
                return(BadRequest("Error occurred in EditEndTask :" + ex.StackTrace));
            }
        }
コード例 #3
0
        //// 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));
            }
        }