예제 #1
0
        // POST api/<controller>
        //

        //public async Task<IHttpActionResult> Post()
        public async Task<IHttpActionResult> Post(OverDetailViewModel detailViewModel)
        {
            try
            {
                var overdetail = _overDetailService.MakeRandomBall(detailViewModel.MatchID, detailViewModel.TeamID);
                
                await _unitOfWorkAsync.SaveChangesAsync();
                var json = JsonConvert.SerializeObject(overdetail);
                var ctx = GlobalHost.ConnectionManager.GetHubContext<MatchHub>();
                var connectionIds = MatchHub._mapping[detailViewModel.MatchID];

                if (connectionIds != null && connectionIds.Any())
                {
                    ctx.Clients.Clients(connectionIds).makeball(json);
                }
                return Ok();
            }
            catch (Exception ex)
            {
            }
            return BadRequest("Can't Bowl At This Moment");
        }
예제 #2
0
        /// <summary>
        /// This Method will be Used For Review
        /// </summary>
        /// <param name="repository"></param>
        /// <param name="detailViewModel"></param>
        /// <returns></returns>
        public static Match GetForReview(this IRepositoryAsync<Match> repository, OverDetailViewModel detailViewModel)
        {
            var matches = repository.Queryable();
            var overDetailsrepo = repository.GetRepositoryAsync<OverDetail>();
            var teams = repository.GetRepository<Team>().Queryable();

            var singlematch = (from m in matches
                               join team1 in teams
            on m.Team1ID equals team1.TeamID
                               join team2 in teams on m.Team2ID equals team2.TeamID
                               where m.MatchID == detailViewModel.MatchID
                               select new { m, team1, team2 }).AsEnumerable()
                              .Select(item => new Match
                              {
                                  MatchID = item.m.MatchID,
                                  FirstTeamName = item.team1.Name,
                                  SecondTeamName = item.team2.Name,
                                  Team1ID = item.m.Team1ID,
                                  Team2ID = item.m.Team2ID,
                                  IsTeam1Bowl = item.m.IsTeam1Bowl,
                                  IsTeam2Bowl = item.m.IsTeam2Bowl
                              }).FirstOrDefault();

            if (singlematch != null)
            {
                var lastBall = overDetailsrepo.GetLastBallByBallNumber(detailViewModel.MatchID,detailViewModel.TeamID,detailViewModel.OverNumber,detailViewModel.BallNumber);
                if (lastBall !=null)
                {
                    singlematch.TotalRun = overDetailsrepo.GetTotalByBallNumber(detailViewModel.MatchID,
                        detailViewModel.TeamID, lastBall.BallIndex);
                }
            }
            return singlematch;
        }