Exemplo n.º 1
0
        /// <summary>
        /// 作者:Vincen
        /// 时间:2014.04.01
        /// 描述:创建课程
        /// </summary>
        /// <param name="course"></param>
        /// <param name="loginUserId"></param>
        /// <returns></returns>
        public static Course CreateCourse(Course course, int loginUserId)
        {
            using (var edb = new EmeEntities())
            {
                try
                {
                    edb.Entry(course).State = EntityState.Added;
                    edb.SaveChanges();
                    return course;
                }
                catch (Exception e)
                {
                    // 异常日志消息队列
                    Common.MSMQ.QueueManager.AddExceptionLog(new ExceptionLogs()
                    {
                        ExceptionType = CommonHelper.To<int>(ExceptionType.Function),
                        Message = string.Format("CourseBLL-CreateCourse:{0};{1};{2}", e.Message, e.InnerException.Message, e.HelpLink),
                        IsTreat = false,
                        CreateBy = loginUserId,
                        CreateTime = DateTime.Now
                    });

                    return null;
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 作者:Primo
        /// 日期:2014.06.24
        /// 描述:新增产品课节
        /// </summary>
        /// <param name="pLevelCourseTypeCourse"></param>
        /// <param name="course"></param>
        /// <returns></returns>
        public static bool CreateProductLevelCourseTypeCourse(ProductLevelCourseTypeCourse pLevelCourseTypeCourse, Course course, int loginUserId)
        {
            using (var edb = new EmeEntities())
            {
                using (var tran = new TransactionScope())
                {
                    try
                    {
                        var result = false;
                        var modelCourse = edb.Course.FirstOrDefault(p => p.CName == course.CName && p.Status == ConvertEnum.StatusTypeForActive);
                        var courseId = 0;

                        edb.Entry(course).State = EntityState.Added;
                        result = edb.SaveChanges() > 0;
                        courseId = course.Id;

                        pLevelCourseTypeCourse.CourseId = courseId;
                        edb.Entry(pLevelCourseTypeCourse).State = EntityState.Added;
                        result = edb.SaveChanges() > 0;
                        tran.Complete();
                        return result;
                    }
                    catch (Exception e)
                    {
                        tran.Dispose();
                        // 异常日志消息队列
                        Common.MSMQ.QueueManager.AddExceptionLog(new ExceptionLogs()
                        {
                            ExceptionType = CommonHelper.To<int>(ExceptionType.Function),
                            Message = string.Format("ProductBLL-CreateProductLevelCourseTypeCourse:{0};{1};{2}", e.Message, e.InnerException.Message, e.HelpLink),
                            IsTreat = false,
                            CreateBy = loginUserId,
                            CreateTime = DateTime.Now
                        });
                        return false;
                    }
                }
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// 作者:Primo
        /// 日期:2014.06.10
        /// 描述:更改产品课节
        /// </summary>
        /// <param name="pLevelCourseTypeCourse"></param>
        /// <param name="course"></param>
        /// <param name="loginUserId"></param>
        /// <returns></returns>
        public static bool UpdateProductLevelCourseTypeCourseAndCourse(ProductLevelCourseTypeCourse pLevelCourseTypeCourse, Course course, int loginUserId)
        {
            using (var edb = new EmeEntities())
            {
                try
                {
                    var courseObj = edb.Course.FirstOrDefault(p => p.Id == course.Id);
                    if (null != courseObj)
                    {
                        courseObj.CName = course.CName;
                        courseObj.EName = course.EName;
                        courseObj.ClassTime = course.ClassTime;
                        courseObj.Description = course.Description;
                        courseObj.StudyTypeId = course.StudyTypeId;
                        courseObj.UpdateBy = course.UpdateBy;
                        courseObj.UpdateTime = course.UpdateTime;
                        edb.Entry(courseObj).State = EntityState.Modified;
                    }

                    var pLevelCourseTypeCourseObj = edb.ProductLevelCourseTypeCourse.FirstOrDefault(p => p.Id == pLevelCourseTypeCourse.Id);
                    if (null != pLevelCourseTypeCourseObj)
                    {
                        pLevelCourseTypeCourseObj.ClassHour = pLevelCourseTypeCourse.ClassHour;
                        pLevelCourseTypeCourseObj.Stage = pLevelCourseTypeCourse.Stage;
                        pLevelCourseTypeCourseObj.Coding = pLevelCourseTypeCourse.Coding;
                        pLevelCourseTypeCourseObj.OrderNum = pLevelCourseTypeCourse.OrderNum;
                        pLevelCourseTypeCourseObj.UpdateBy = pLevelCourseTypeCourse.UpdateBy;
                        pLevelCourseTypeCourseObj.UpdateTime = pLevelCourseTypeCourse.UpdateTime;

                        edb.Entry(pLevelCourseTypeCourseObj).State = EntityState.Modified;
                    }

                    return edb.SaveChanges() > 0;
                }
                catch (Exception e)
                {
                    // 异常日志消息队列
                    Common.MSMQ.QueueManager.AddExceptionLog(new ExceptionLogs()
                    {
                        ExceptionType = CommonHelper.To<int>(ExceptionType.Function),
                        Message = string.Format("ProductBLL-UpdateProductLevelCourseTypeCourseAndCourse:{0};{1};{2}", e.Message, e.InnerException.Message, e.HelpLink),
                        IsTreat = false,
                        CreateBy = loginUserId,
                        CreateTime = DateTime.Now
                    });

                    return false;
                }
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// 作者:Raymond
        /// 日期:2014-3-28
        /// 描述:更新课节
        /// </summary>
        /// <param name="course"></param>
        /// <returns></returns>
        public static bool UpdateCourse(Course course)
        {
            using (var edb = new EmeEntities())
            {
                var model = edb.Course.FirstOrDefault(p => p.Id == course.Id);
                if (null == model)
                    return false;

                model.V3CourseId = course.V3CourseId;
                model.CName = course.CName;
                model.EName = course.EName;
                model.Description = course.Description;
                model.ClassTime = course.ClassTime;
                model.StudyTypeId = course.StudyTypeId;
                model.OrderNum = course.OrderNum;
                model.Status = course.Status;
                model.UpdateBy = course.UpdateBy;
                model.UpdateTime = DateTime.Now;
                model.Remark = course.Remark;
                edb.Entry(model).State = EntityState.Modified;
                return edb.SaveChanges() > 0;
            }
        }