Exemplo n.º 1
0
        public ActionResult DeleteTask(TaskJsonRequest request)
        {
            var result = new ProjectPhaseBLL().GetDataById(request.projectPhaseId);

            if (result == null)
            {
                return(Json(new ResponseEntity <int>(false, "阶段不存在", 0), JsonRequestBehavior.AllowGet));
            }

            var tasks = new List <Task>();

            if (!string.IsNullOrEmpty(result.TaskJson))
            {
                tasks = JsonConvert.DeserializeObject <List <Task> >(result.TaskJson);
            }

            if (request.task.id != 0) //更新
            {
                var targetTask = tasks.FirstOrDefault(t => t.id == request.task.id);
                tasks.Remove(targetTask);
            }

            string taskJson = JsonConvert.SerializeObject(tasks);

            var updateResult = new ProjectPhaseBLL().UpdateTask(request.projectPhaseId, taskJson);
            var response     = new ResponseEntity <int>(updateResult.Success, updateResult.Message, updateResult.Data);

            new LogBLL().LogEvent(CurrenUserInfo.LoginName, GDS.Entity.Constant.ConstantDefine.ModuleProject,
                                  GDS.Entity.Constant.ConstantDefine.TypeUpdate, GDS.Entity.Constant.ConstantDefine.ActionUpdateProjectPhase, $"{request.projectPhaseId}");

            return(Json(response, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 2
0
        public ActionResult UpdateTask(TaskJsonRequest request)
        {
            var result = new ProjectPhaseBLL().GetDataById(request.projectPhaseId);

            if (result == null)
            {
                return(Json(new ResponseEntity <int>(false, "阶段不存在", 0), JsonRequestBehavior.AllowGet));
            }

            var tasks = new List <Task>();

            if (!string.IsNullOrEmpty(result.TaskJson))
            {
                tasks = JsonConvert.DeserializeObject <List <Task> >(result.TaskJson);
            }

            if (!request.newTask) //更新
            {
                var targetTask = tasks.FirstOrDefault(t => t.id == request.task.id);
                if (targetTask.id != 0)
                {
                    targetTask.subject     = request.task.subject;
                    targetTask.log         = request.task.log;
                    targetTask.owner       = request.task.owner;
                    targetTask.description = request.task.description;
                    //targetTask.detail = request.task.detail;
                    targetTask.startTime  = request.task.startTime;
                    targetTask.endTime    = request.task.endTime;
                    targetTask.updateTime = request.task.updateTime;
                    targetTask.workaround = request.task.workaround;
                    targetTask.status     = request.task.status;
                }
            }
            else   //插入新的task
            {
                tasks.Add(request.task);
            }

            string taskJson = JsonConvert.SerializeObject(tasks);

            var updateResult = new ProjectPhaseBLL().UpdateTask(request.projectPhaseId, taskJson);
            var response     = new ResponseEntity <int>(updateResult.Success, updateResult.Message, updateResult.Data);

            new LogBLL().LogEvent(CurrenUserInfo.LoginName, GDS.Entity.Constant.ConstantDefine.ModuleProject,
                                  GDS.Entity.Constant.ConstantDefine.TypeUpdate, GDS.Entity.Constant.ConstantDefine.ActionUpdateProjectPhase, $"{request.projectPhaseId}");

            return(Json(response, JsonRequestBehavior.AllowGet));
        }