示例#1
0
        //修改组别信息
        public bool EditGroup(EventGroupRequest request, out string msg)
        {
            bool flag = false;

            msg = string.Empty;
            try
            {
                if (request.Name.IsEmpty())
                {
                    msg = "赛事组别名称不能为空";
                    return(flag);
                }
                t_event_group eventgroup = _dbContext.Get <t_event_group>(request.Id);
                if (eventgroup != null)
                {
                    eventgroup.name       = request.Name;
                    eventgroup.maxgrade   = request.MaxGrade;
                    eventgroup.mingrade   = request.MinGrade;
                    eventgroup.mintimes   = request.MinTimes;
                    eventgroup.maxtimes   = request.MaxTimes;
                    eventgroup.updatetime = DateTime.Now;
                    _dbContext.Update(eventgroup);
                    flag = true;
                }
                else
                {
                    msg = "未找到赛事组别信息";
                }
            }
            catch (Exception ex)
            {
                flag = false;
                msg  = "服务异常";
                LogUtils.LogError("EventService.EditGroup", ex);
            }
            return(flag);
        }
示例#2
0
        //新增临时选手
        public bool InsertTempPlayer(List <TempPlayerRequest> request, int memberId, out string msg)
        {
            bool flag = false;

            msg = string.Empty;
            try
            {
                if (request == null || request.Count == 0)
                {
                    msg = "请先录入数据";
                    return(flag);
                }
                TempPlayerRequest tempplayer = request.FirstOrDefault();
                t_event           t_event    = _dbContext.Get <t_event>(tempplayer.EventId);
                if (t_event == null)
                {
                    msg = "赛事信息有误";
                    return(flag);
                }
                if (t_event.eventStatus != EventStatusEm.比赛中)
                {
                    msg = "只有赛事当天才能添加临时选手";
                    return(flag);
                }
                t_event_group t_group = _dbContext.Get <t_event_group>(tempplayer.EventGroupId);
                if (t_group == null)
                {
                    msg = "赛事组别信息有误";
                    return(flag);
                }
                if (t_group.teamnumber != request.Count)
                {
                    msg = "队伍人数有误";
                    return(flag);
                }
                foreach (var item in request)
                {
                    if (item.Name.IsEmpty())
                    {
                        msg = "姓名不能为空";
                        break;
                    }
                    if (item.ContactMobile.IsEmpty())
                    {
                        msg = "联系方式不能为空";
                        break;
                    }
                    if (item.SchoolId <= 0)
                    {
                        msg = "教育经历不能为空";
                        break;
                    }
                }
                if (msg.IsNotEmpty())
                {
                    return(flag);
                }
                var eventdate = _dbContext.Select <t_event_matchdate>(c => c.eventId == tempplayer.EventId);
                try
                {
                    _dbContext.BeginTransaction();
                    string groupnum = _dataRepository.SignUpPlayerRepo.RenderCode(tempplayer.EventId);
                    foreach (var item in request)
                    {
                        //创建账号
                        string   code   = _dataRepository.MemberRepo.RenderCode("nsda");
                        t_member member = new t_member
                        {
                            code            = code,
                            account         = item.Name,
                            pwd             = item.ContactMobile,
                            memberStatus    = MemberStatusEm.待认证,
                            memberType      = MemberTypeEm.临时选手,
                            isExtendCoach   = false,
                            isExtendPlayer  = false,
                            isExtendReferee = false
                        };
                        int memberInsertId = _dbContext.Insert(member).ToObjInt();
                        _dbContext.Insert(new t_member_player
                        {
                            memberId               = memberInsertId,
                            code                   = code,
                            card                   = item.Name,
                            cardType               = CardTypeEm.身份证,
                            completename           = item.Name,
                            completepinyin         = item.Name,
                            name                   = item.Name,
                            contactaddress         = item.Name,
                            contactmobile          = item.ContactMobile,
                            emergencycontact       = item.Name,
                            emergencycontactmobile = item.ContactMobile,
                            gender                 = GenderEm.未知,
                            pinyinname             = item.Name,
                            pinyinsurname          = item.Name,
                            surname                = item.Name
                        });
                        _dbContext.Insert(new t_member_points
                        {
                            memberId      = memberInsertId,
                            playerPoints  = 0,
                            coachPoints   = 0,
                            refereePoints = 0
                        });
                        _dbContext.Insert(new t_member_temp
                        {
                            code          = groupnum,
                            contactmobile = item.ContactMobile,
                            name          = item.Name,
                            eventId       = item.EventId,
                            memberId      = memberInsertId,
                            tempStatus    = TempStatusEm.待绑定,
                            tempType      = TempTypeEm.临时选手
                        });
                        //报名表
                        _dbContext.Insert(new t_event_player_signup
                        {
                            groupnum     = groupnum,
                            eventId      = item.EventId,
                            eventGroupId = item.EventGroupId,
                            isTemp       = true,
                            memberId     = memberInsertId,
                            signfee      = t_event.signfee,
                            signUpStatus = SignUpStatusEm.报名成功,
                            signUpType   = SignUpTypeEm.临时添加
                        });
                        _dbContext.Insert(new t_player_edu
                        {
                            startdate = DateTime.Now.AddYears(-1).ToString("yyyy-MM"),
                            enddate   = "",
                            memberId  = memberInsertId,
                            schoolId  = item.SchoolId
                        });

                        //生成签到表
                        foreach (var itemdate in eventdate)
                        {
                            _dbContext.Insert(new t_event_sign
                            {
                                eventGroupId    = tempplayer.EventGroupId,
                                eventId         = tempplayer.EventId,
                                eventSignType   = EventSignTypeEm.手,
                                eventSignStatus = EventSignStatusEm.待签到,
                                signdate        = itemdate.eventMatchDate,
                                memberId        = memberInsertId,
                                isStop          = false
                            });
                        }
                    }
                    _dbContext.CommitChanges();
                    flag = true;
                }
                catch (Exception ex)
                {
                    flag = false;
                    msg  = "服务异常";
                    _dbContext.Rollback();
                    LogUtils.LogError("MemberTempService.InsertTempPlayerTran", ex);
                }
            }
            catch (Exception ex)
            {
                flag = false;
                msg  = "服务异常";
                LogUtils.LogError("MemberTempService.InsertTempPlayer", ex);
            }
            return(flag);
        }