Example #1
0
        /// <summary>
        /// 为场馆添加一个学生
        /// </summary>
        /// <param name="student">学生信息</param>
        /// <returns></returns>
        public static bool Create(Sys.Models.Student student)
        {
            //todo 并发暂时不考虑

            /*
             * 检查场馆code是否存在
             * 检查学生信息是否存在
             * 检查学生场馆绑定关系是否存在
             * 插入绑定关系
             * 插入学生信息和绑定关系
             *
             */

            try
            {
                bool isExistVenueCode = VenueService.IsExistVenueCode(student.VenueID.Value);

                if (!isExistVenueCode)
                {
                    throw new Comm.YYException.YYException("场馆编码不存在");
                }

                bool isExistStudent = IsExist(student);

                if (isExistStudent)//学生已经存在
                {
                    bool isExistStudentVenue = IsExistInVenue(student);

                    if (isExistStudentVenue)
                    {
                        throw new Comm.YYException.YYException(student.FullName + "学生已经绑定");
                    }

                    var student_info = FindStudentByUserName(student.UserName);

                    var student_venue_result = Comm.Helper.DapperHelper.Instance.Insert(new Sys.Models.Student_Venue()
                    {
                        AddTime   = DateTime.Now,
                        StudentID = student_info.StudentID,
                        VenueID   = student.VenueID,
                    });
                    return(student_venue_result > 0);
                }
                else//学生不存在
                {
                    return(ImportStudent(student));
                }
            }
            catch (Comm.YYException.YYException)
            {
                throw;
            }
            catch (Exception ex)
            {
                logs.Error("学生添加失败", ex);
                return(false);
            }
        }
Example #2
0
        /// <summary>
        /// 为场馆添加一个
        /// </summary>
        /// <param name="coach">教练信息</param>
        /// <returns></returns>
        public static bool Create(Sys.Models.Coach coach)
        {
            //todo 并发暂时不考虑
            try
            {
                bool isExistVenueCode = VenueService.IsExistVenueCode(coach.VenueID.Value);

                if (!isExistVenueCode)
                {
                    throw new Comm.YYException.YYException("场馆编码不存在");
                }

                bool isExistCoach = IsExist(coach);

                if (!isExistCoach)
                {
                    return(ImportCoach(coach));
                }
                else
                {
                    bool isExistStudentVenue = IsExistInVenue(coach);
                    if (isExistStudentVenue)
                    {
                        throw new Comm.YYException.YYException(coach.FullName + "教练已经绑定");
                    }

                    var coach_info = FindCoachByUserName(coach.UserName);

                    var coach_venue_result = Comm.Helper.DapperHelper.Instance.Insert(new Sys.Models.Coach_Venue()
                    {
                        AddTime = DateTime.Now,
                        CoachID = coach_info.CoachID,
                        VenueID = coach.VenueID,
                    });
                    return(coach_venue_result > 0);
                }
            }
            catch (Comm.YYException.YYException)
            {
                throw;
            }
            catch (Exception ex)
            {
                logs.Error("教练添加失败", ex);
                return(false);
            }
        }