示例#1
0
        /// <summary>
        /// 调整
        /// </summary>
        /// <param name="Cid"></param>
        /// <param name="reason"></param>
        /// <param name="type">0 修改  1删除</param>
        /// <returns></returns>
        public JsonResult AdjustClass(int Cid, string reason, int type = 0)
        {
            try
            {
                var model = _classManager.GetTrTrainClassById(Cid);
                //删除调整之前的数据
                model.UpdateReason   = reason;
                model.LastUpdateTime = DateTime.Now;
                if (type == 0)
                {
                    model.UpdateType = 2;
                    model.IsDelete   = 1;
                }
                _classManager.UpdateTrainClass(model);

                var newClass = model.Clone();
                newClass.ClassId       = 0;
                newClass.IsDelete      = 0;
                newClass.CreateTime    = DateTime.Now;
                newClass.CreateUserID  = CurrentUser.UserId;
                newClass.DeptID        = model.ClassType > 0 ? CurrentUser.DeptId : xingzhengId;
                newClass.ApproveStatus = 0;
                newClass.UpdateType    = model.UpdateType;
                newClass.UpdateReason  = model.UpdateReason;
                newClass.OldClassId    = model.ClassId;
                _classManager.AddTrainClass(newClass);

                //同步所有资源
                _classManager.UpdateResourceClassId(newClass.ClassId, newClass.OldClassId);

                return(Json(new { result = 1, content = "调整成功", classId = newClass.ClassId }, JsonRequestBehavior.AllowGet));
            }
            catch
            {
                return(Json(new { result = 0, content = "调整失败" }, JsonRequestBehavior.AllowGet));
            }
        }