Пример #1
0
        public async Task <IActionResult> EditContestant(EditContestantInCompetitionViewModel model, int heatId, int eventId, int competitionId, int competitionInstanceId)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    var entity = (from e in model.Event
                                  where e.HeatId == heatId
                                  select new ContestantInHeat
                    {
                        UserId = model.UserId,
                        HeatId = e.HeatId,
                        Bib = e.Bib,
                        Team = e.Team,
                        Modified = DateTime.Now
                    }).SingleOrDefault();

                    await _heatService.EditAsyncContestantInHeat(entity);
                }
                catch (Exception e)
                {
                    return(Json(e.Message));
                }
                return(RedirectToAction("Heat", "Admin", new { heatId, eventId, competitionId, competitionInstanceId }));
            }
            return(View(model));
        }
Пример #2
0
        public async Task <IActionResult> EditContestant(int heatId, int eventId, int competitionId, int competitionInstanceId, string userId)
        {
            //Working on this!!!
            IEnumerable <ContestantInEventViewModel> events = Enumerable.Empty <ContestantInEventViewModel>();
            var e = await _heatService.GetContestantInEventViewModelAsync(userId, heatId);

            events.Append(e);
            var r = _resultService.GetResult(userId, heatId);
            var u = await _adminService.GetUserByIdAsync(userId);

            var model = new EditContestantInCompetitionViewModel
            {
                Name        = r.Name,
                Nationality = u.Nationality,
                Phone       = u.Phone,
                UserId      = userId,
                Year        = u.DateOfBirth.Year,
                Event       = events
            };

            return(View(model));
        }