public async Task <IActionResult> NewMatchListAsync(NewMatch newmatch)
        {
            db.NewMatches.Add(newmatch);
            await db.SaveChangesAsync();

            return(RedirectToAction("NewMatchList"));
        }
 public static Match CreateMatch(NewMatch matchPost)
 {
     return(new Match()
     {
         Day = matchPost.Day,
         Type = matchPost.Type,
         Year = matchPost.Year,
         FirstTeamId = matchPost.Results[0].TeamId,
         FirstTeamPenalty = matchPost.Results[0].Penalty,
         FirstTeamScore = matchPost.Results[0].Score,
         SecondTeamId = matchPost.Results[1].TeamId,
         SecondTeamPenalty = matchPost.Results[1].Penalty,
         SecondTeamScore = matchPost.Results[1].Score
     });
 }
Example #3
0
        public NewMatch PostMatch([FromBody] NewMatch nm)
        {
            var cs       = Services.ContentService;
            var newMatch = cs.CreateContent(nm.Opponent, nm.TeamId, "matchItem");

            cs.SaveAndPublishWithStatus(newMatch);


            NewMatch team = new NewMatch
            {
                TeamId   = nm.TeamId,
                Opponent = nm.Opponent
            };

            return(team);
        }
Example #4
0
        public async Task <ActionResult> Create(NewMatch newMatch)
        {
            if (ModelState.IsValid)
            {
                using (MemoryStream ms = new MemoryStream())
                {
                    await newMatch.Screenshot.CopyToAsync(ms);

                    ms.Seek(0, SeekOrigin.Begin);
                    await _matchService.RegisterMatchResult(newMatch.MatchId, newMatch.HostGoalsScored, newMatch.GuestGoalsScored, ms);
                }

                return(RedirectToAction("", ""));
            }

            return(View(newMatch));
        }
        public async Task <IActionResult> NewMatchDetail(NewMatchDetailViewModel viewModel)
        {
            if (ModelState.IsValid)
            {
                //Database query.
                NewMatch newmatch = await db.NewMatches
                                    .SingleOrDefaultAsync(m => m.newMatchId == viewModel.NewMatchID);

                if (newmatch == null)
                {
                    return(NotFound());
                }


                viewModel = await GetNewMatchDetailViewModelFromNewMatch(newmatch);
            }
            return(View(viewModel));
        }
        protected override void OnAppearing()
        {
            base.OnAppearing();

            _newMatch?.Dispose();
            _viewMoreListPage?.Dispose();
            _viewMoreListPage = null;
            _newMatch         = null;

            _matches = App.DataManager.GetMatches((m) => true).OrderByDescending(m => m.Date).Take(4).ToList();


            RecentListView.ItemTemplate = new DataTemplate(() => new RecentViewCell());
            RecentListView.ItemsSource  = _matches;
            RecentListView.RowHeight    = 60;

            StartMatchTapped.Tapped += StartMatchButtonTapped;
        }
        /// <summary>
        /// HttpGet method for viewing new match detail.
        /// </summary>
        /// <param name="id"></param>
        /// <returns>View and viewmodel</returns>
        public async Task <IActionResult> NewMatchDetail(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }
            //Database query.
            NewMatch newmatch = await db.NewMatches
                                .SingleOrDefaultAsync(m => m.newMatchId == id);

            if (newmatch == null)
            {
                return(NotFound());
            }

            NewMatchDetailViewModel viewModel = await GetNewMatchDetailViewModelFromNewMatch(newmatch);

            return(View(viewModel));
        }
        private bool disposedValue; // To detect redundant calls

        protected virtual void Dispose(bool disposing)
        {
            if (!disposedValue)
            {
                if (disposing)
                {
                    // dispose managed state (managed objects).
                    _matches?.Clear();
                    _newMatch?.Dispose();
                    _viewMoreListPage?.Dispose();
                }

                // free unmanaged resources (unmanaged objects) and override a finalizer below.
                // set large fields to null.
                _matches          = null;
                _viewMoreListPage = null;
                _newMatch         = null;
                disposedValue     = true;
            }
        }
Example #9
0
        public async Task <ActionResult> Create(NewMatch newMatch)
        {
            if (ModelState.IsValid && Request.Files.Count > 0)
            {
                using (MemoryStream ms = new MemoryStream())
                {
                    await Request.Files[0].InputStream.CopyToAsync(ms);
                    await _matchService.RegisterMatchResult(newMatch.MatchId, newMatch.HostGoalsScored, newMatch.GuestGoalsScored, ms);
                }

                return(RedirectToAction("", ""));
            }

            if (Request.Files.Count == 0)
            {
                ModelState.AddModelError("required_screenshot", "Screenshot is required");
            }

            return(View(newMatch));
        }
        /// <summary>
        /// Set new match object for viewmodel.
        /// </summary>
        /// <param name="newmatch"></param>
        /// <returns>viewModel</returns>
        private async Task <NewMatchDetailViewModel> GetNewMatchDetailViewModelFromNewMatch(NewMatch newmatch)
        {
            NewMatchDetailViewModel viewModel = new NewMatchDetailViewModel();

            viewModel.NewMatch = newmatch;

            return(viewModel);
        }
 private void OnNewMatch(MatchDetails match)
 {
     NewMatch?.Invoke(this, match);
 }
Example #12
0
 private async void StartMatchButtonTapped(object sender, EventArgs e)
 {
     _newMatch = new NewMatch(App.DataManager.CreateNewMatch());
     await Navigation.PushAsync(_newMatch, true);
 }