Example #1
0
        // PUT api/Contests/5
        public ContestDto Put([FromBody] ContestDto contest)
        {
            var updatedContest = contest.ConvertFromDto();

            ContestService.Update(updatedContest);
            return(updatedContest.ConvertToDto());
        }
Example #2
0
        // POST api/Contests
        public ContestDto Post([FromBody] ContestDto contest)
        {
            var newContest = contest.ConvertFromDto();

            ContestService.Add(newContest);
            return(newContest.ConvertToDto());
        }
Example #3
0
        public ContestDto GetShowContests(int id, [FromBody] ContestDto contest)
        {
            var showId     = id;
            var newContest = contest.ConvertFromDto();

            ContestService.AddShowContest(showId, newContest);
            return(newContest.ConvertToDto());
        }
Example #4
0
        public ActionResult Contest()
        {
            var model = new ContestDto();

            var league = League.Cache.Load(ConfigGlobal_AcnCasino.DefaultLeagueID);

            if (league != null)
            {
                var list = GamblerDW.All(league.ID);

                if (list != null && list.Count > 0)
                {
                    // 进入最终名次排行榜的标准(评选要求)同时满足以下3个条件:
                    //1、赛季中必须投注博采币次数达到5个单场及以上(反复多次投注同一场比赛只能算是1次);
                    //2、赛季中参与累计投注量达到5,000菠菜币及以上;
                    //3、赛季中并且获得RP+3及以上,即猜对本赛季3场以上的比赛比分。
                    if (!ConfigGlobal_AcnCasino.ContestLimitIgnore)
                    {
                        list = list.FindAll(g => g.MatchBet >= ConfigGlobal_AcnCasino.ContestCondition[0]
                                                 && g.TotalBet >= ConfigGlobal_AcnCasino.ContestCondition[1] &&
                                                 g.RPBonus >= ConfigGlobal_AcnCasino.ContestCondition[2]);
                    }

                    var tbs = ConfigGlobal_AcnCasino.TotalBetStandard;

                    var listUpper = list.FindAll(g => g.TotalBet >= tbs);

                    var listLower = list.FindAll(g => g.TotalBet < tbs);

                    if (listUpper.Count > 0)
                    {
                        listUpper = GamblerDW.SortRank(listUpper);
                    }

                    if (listLower.Count > 0)
                    {
                        listLower = GamblerDW.SortRank(listLower);
                    }

                    model.UpperGamblers = listUpper.Take(6);
                    model.LowerGamblers = listLower.Take(6);
                }

                model.RankCondition = ConfigGlobal_AcnCasino.ContestCondition;
                model.ContestLeague = league;
            }

            return View(model);
        }
Example #5
0
        public ActionResult Contest()
        {
            var model = new ContestDto();

            var league = League.Cache.Load(ConfigGlobal_AcnCasino.DefaultLeagueID);

            if (league != null)
            {
                var list = GamblerDW.All(league.ID);

                if (list != null && list.Count > 0)
                {
                    // 进入最终名次排行榜的标准(评选要求)同时满足以下3个条件:
                    //1、赛季中必须投注博采币次数达到5个单场及以上(反复多次投注同一场比赛只能算是1次);
                    //2、赛季中参与累计投注量达到5,000菠菜币及以上;
                    //3、赛季中并且获得RP+3及以上,即猜对本赛季3场以上的比赛比分。
                    if (!ConfigGlobal_AcnCasino.ContestLimitIgnore)
                    {
                        list = list.FindAll(g => g.MatchBet >= ConfigGlobal_AcnCasino.ContestCondition[0] &&
                                            g.TotalBet >= ConfigGlobal_AcnCasino.ContestCondition[1] &&
                                            g.RPBonus >= ConfigGlobal_AcnCasino.ContestCondition[2]);
                    }

                    var tbs = ConfigGlobal_AcnCasino.TotalBetStandard;

                    var listUpper = list.FindAll(g => g.TotalBet >= tbs);

                    var listLower = list.FindAll(g => g.TotalBet < tbs);

                    if (listUpper.Count > 0)
                    {
                        listUpper = GamblerDW.SortRank(listUpper);
                    }

                    if (listLower.Count > 0)
                    {
                        listLower = GamblerDW.SortRank(listLower);
                    }

                    model.UpperGamblers = listUpper.Take(6);
                    model.LowerGamblers = listLower.Take(6);
                }

                model.RankCondition = ConfigGlobal_AcnCasino.ContestCondition;
                model.ContestLeague = league;
            }

            return(View(model));
        }
        public async Task <IActionResult> UpdateContest(ContestDto dto)
        {
            try
            {
                await _contestService.UpdateContest(dto);

                return(Ok());
            }
            catch (NotFoundException)
            {
                return(NotFound("Конкурс не найден"));
            }
            catch (ValidationException)
            {
                return(BadRequest("Неправильный формат одного или нескольких параметров"));
            }
        }
Example #7
0
        public async Task UpdateContest(ContestDto dto)
        {
            var entity = await _db.Contests.FirstOrDefaultAsync(x => x.Id == dto.Id);

            if (entity == null)
            {
                throw new NotFoundException();
            }

            if (!dto.IsDtoValid())
            {
                throw new ValidationException();
            }

            entity = _mapper.Map <ContestDto, ContestEntity>(dto);

            _db.Contests.Update(entity);
            await _db.SaveChangesAsync();
        }
Example #8
0
 // DELETE api/Contests/5
 public void Delete([FromBody] ContestDto contest)
 {
     ContestService.Delete(contest.ConvertFromDto());
 }
Example #9
0
 public static Contest ConvertFromDto(this ContestDto contestDto)
 {
     return(new Contest(contestDto.Id, contestDto.Name, contestDto.Description, contestDto.TimeKeeperId, contestDto.MaxDuration, status: "Pending"));
 }