Beispiel #1
0
 public async Task <DateNameEntity> ToDateNameEntityAsync(DateNameViewModel model, bool isNew)
 {
     return(new DateNameEntity
     {
         Id = isNew ? 0 : model.Id,
         Matches = model.Matches,
         Name = model.Name,
         Tournament = await _context.Tournaments.FindAsync(model.TournamentId)
     });
 }
Beispiel #2
0
        public async Task <IActionResult> EditDateName(DateNameViewModel model)
        {
            if (ModelState.IsValid)
            {
                var dateNameEntity = await _converterHelper.ToDateNameEntityAsync(model, false);

                _context.Update(dateNameEntity);
                await _context.SaveChangesAsync();

                return(RedirectToAction($"{nameof(Details)}/{model.TournamentId}"));
            }

            return(View(model));
        }
Beispiel #3
0
        public async Task <IActionResult> AddDateName(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            var tournamentEntity = await _context.Tournaments.FindAsync(id);

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

            var model = new DateNameViewModel
            {
                Tournament   = tournamentEntity,
                TournamentId = tournamentEntity.Id
            };

            return(View(model));
        }