示例#1
0
        ///// <summary>
        ///// 新建训练人员模型
        ///// </summary>
        ///// <param name="empoyeesNew"></param>
        ///// <returns></returns>
        //public ActionResult<bool> AddTrainEmployee(DocTrainEmpoyeesNew empoyeesNew)
        //{
        //    try
        //    {
        //        var check = _rpsdtemp.Any(p=>p.TrainID==empoyeesNew.TrainID);
        //        if (!check)
        //        {
        //            throw new Exception("未找到该培训项");
        //        }
        //        check = _rpsdtemp.Any(p => p.TrainID == empoyeesNew.TrainID && p.EmployeeID == empoyeesNew.EmployeeID);
        //        if (check)
        //        {
        //            throw new Exception("该培训项下已存在该人员");
        //        }
        //        var dbdtemp = empoyeesNew.MAPTO<Doc_TrainEmpoyees>();
        //        _rpsdtemp.Add(dbdtemp);
        //        _work.Commit();
        //        return new ActionResult<bool>(true);
        //    }
        //    catch (Exception ex)
        //    {
        //        return new ActionResult<bool>(ex);
        //    }
        //}
        /// <summary>
        /// 新建训练模型
        /// </summary>
        /// <param name="trainingNew"></param>
        /// <returns></returns>
        public ActionResult <bool> AddTraining(DocTrainingNew trainingNew)
        {
            try
            {
                if (trainingNew == null)
                {
                    throw new Exception("参数有误");
                }
                var check = _rpsdt.Any(p => p.Motif == trainingNew.Motif);
                if (check)
                {
                    throw new Exception("该训练项已存在");
                }
                var dbdt = trainingNew.MAPTO <Doc_Training>();
                //电子文档
                var files = new AttachFileSave
                {
                    BusinessID = dbdt.ID,
                    files      = from f in trainingNew.AttachFiles
                                 select new AttachFileNew
                    {
                        FileTitle = f.FileTitle,
                        FileType  = f.FileType,
                        FileUrl   = f.FileUrl
                    }
                };

                var fileresult = srvFile.SaveFiles(files);
                if (fileresult.state != 200)
                {
                    throw new Exception(fileresult.msg);
                }
                //添加培训人员
                List <Doc_TrainEmpoyees> emps = (from empid in trainingNew.EmployeeIDs
                                                 select new Doc_TrainEmpoyees
                {
                    EmployeeID = empid,
                    TrainID = dbdt.ID
                }).ToList();

                _rpsdtemp.Add(emps);
                _rpsdt.Add(dbdt);
                _work.Commit();
                return(new ActionResult <bool>(true));
            }
            catch (Exception ex)
            {
                return(new ActionResult <bool>(ex));
            }
        }
示例#2
0
 public ActionResult <bool> AddTraining(DocTrainingNew trainingNew)
 {
     LogContent = "新建了训练项模型,参数源:" + JsonConvert.SerializeObject(trainingNew);
     return(bll.AddTraining(trainingNew));
 }