Example #1
0
        public async Task <IViewComponentResult> InvokeAsync(MatchResource matchResource, string subMajorId, bool viewMode)
        {
            List <MatchResourceUploadList> uploadList = new List <MatchResourceUploadList>();

            try
            {
                uploadList = matchResource.GetData <List <MatchResourceUploadList> >("Datas");
            }
            catch
            {
            }
            ViewData["subMajorId"] = subMajorId;
            var subMajorName = "基本信息";

            if (!string.IsNullOrEmpty(subMajorId))
            {
                subMajorName = "专业" + (await MajorManager.GetByIdAsync(int.Parse(subMajorId))).BriefName;
            }
            ViewData["subMajorName"] = subMajorName;

            var viewName = "Default";

            if (viewMode)
            {
                viewName = "View";
            }
            return(View(viewName, uploadList));
        }
Example #2
0
        public async Task<IActionResult> New()
        {
            var matchResource = new MatchResource();
            matchResource.Date = DateTime.Now;
            matchResource.Teams = await teamRepository.GetTeams();

            return View("Match", matchResource);
        }
Example #3
0
        public async Task <IActionResult> AddMatch([FromBody] MatchResource matchResource)
        {
            var match = mapper.Map <MatchResource, Match>(matchResource);

            context.Matches.Add(match);

            await context.SaveChangesAsync();

            return(Ok(matchResource));
        }
Example #4
0
        /// <summary>
        /// 获取评选活动的打分表
        /// </summary>
        /// <param name="reviewId"></param>
        /// <returns></returns>
        public virtual async Task <List <MatchResourceRateTable> > GetRateTable(Review review)
        {
            var matchResource = await MatchResourceRepository.GetAll().Where(o => o.MatchInstanceId == review.MatchInstanceId && o.MatchResourceStatus == MatchResourceStatus.Publish && o.MatchResourceType == MatchResourceType.RateTable && o.MajorId == review.MajorId && o.SubMajorId == review.SubMajorId).FirstOrDefaultAsync();

            List <MatchResourceRateTable> result = null;

            if (matchResource != null)
            {
                result = new MatchResource <MatchResourceRateTable>(matchResource).Datas;
            }

            return(result);
        }
Example #5
0
        public async Task<IActionResult> AddMatch(MatchResource matchResource)
        {
            if (!ModelState.IsValid)
            {
                var matchRes = new MatchResource();
                matchRes.Date = DateTime.Now;
                matchRes.Teams = await teamRepository.GetTeams();

                return View("Match", matchRes);
                
            }
            await matchRepository.AddMatch(matchResource);

            return RedirectToAction("Index", "Home");
        }
        public async Task <MatchResource> CreateMatch([FromBody] MatchResource matchResource)
        {
            // if (!ModelState.IsValid)
            //     return BadRequest(ModelState);

            var match = _mapper.Map <MatchResource, Match>(matchResource);

            _repository.Add(match);
            await _unitOfWork.CompleteAsync();

            match = await _repository.GetMatch(match.Id);

            var result = _mapper.Map <Match, MatchResource>(match);

            return(result);
        }
Example #7
0
        public async Task AddMatch(MatchResource matchResource)
        {
            matchResource.CashReturn = Math.Round(matchResource.Stake * matchResource.Odd, 2);

            var match = mapper.Map <MatchResource, Match>(matchResource);

            context.Matches.Add(match);

            var bet = new Bet();

            bet.MatchId = match.Id;

            context.Bets.Add(bet);

            await context.SaveChangesAsync();
        }
        public async Task <IViewComponentResult> InvokeAsync(MatchResource matchResource, int location)
        {
            List <MatchResourceDownloadList> downloadList = new List <MatchResourceDownloadList>();

            try
            {
                downloadList = matchResource.GetData <List <MatchResourceDownloadList> >("Datas")
                               .Where(o => o.FileLocation == location)
                               .OrderBy(o => o.Sort)
                               .ToList();
            }
            catch
            {
            }

            return(View(downloadList));
        }