Esempio n. 1
0
        public ActionResult Report(MatchReportViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            var request = new EventReportRequest {
                ClubId         = club.Guid,
                CoachsRemarks  = model.CoachsRemarks,
                EventId        = model.EventId,
                GoalsConceeded = model.GoalsConceeded.Value,
                GoalsScored    = model.GoalsScored.Value,
                Opponent       = model.Opponent,
                Scorers        = model.Scorers
            };

            var response = eventService.UpdateEventReport(request);

            if (!response.RequestIsFulfilled)
            {
                foreach (var error in response.Errors)
                {
                    ModelState.AddModelError("", error);
                }

                var @event = eventsQuery.GetEvent(model.EventId);
                model.EventTitle   = @event.Title;
                model.EventDetails = $"{@event.EventType.GetDescription()} {@event.StartDate.ToString("ddd dd-MMM-yyyy h:mm tt")}<br/>{@event.Location}<br/>{string.Join(", ", @event.Squads.Select(s => s.Name))}";
                model.Players      = GetSquadPlayersForEvent(@event);
                return(View(model));
            }
            return(RedirectToAction(nameof(Report)));
        }
Esempio n. 2
0
        public IActionResult NewMatchReportAdded(MatchReportViewModel matchreport)
        {
            if (!ModelState.IsValid)
            {
                return(RedirectToAction("NewReport", "Reports"));
            }

            try
            {
                MatchReport newreport = new MatchReport(0, DateTime.Now, matchreport.Title, matchreport.Report, null);
                MatchReportCollection.AddMatchReport(newreport);
                return(RedirectToAction("Oversight", "Reports"));
            }
            catch (AddMatchReportFailedException exception)
            {
                ModelState.AddModelError("", exception.Message);
                return(RedirectToAction("NewReport", "Reports"));
            }
        }
Esempio n. 3
0
        public ActionResult Report(Guid eventId)
        {
            var @event      = eventsQuery.GetEvent(eventId);
            var eventReport = eventsQuery.GetEventReport(eventId);
            var matchReport = eventService.DeserializeReport <MatchReport>(eventReport?.Report);


            var model = new MatchReportViewModel()
            {
                EventTitle     = @event.Title,
                EventDetails   = $"{@event.EventType.GetDescription()} {@event.StartDate.ToString("ddd dd-MMM-yyyy h:mm tt")}<br/>{@event.Location}<br/>{string.Join(", ", @event.Squads.Select(s => s.Name))}",
                CoachsRemarks  = matchReport?.CoachsRemarks,
                GoalsConceeded = matchReport?.GoalsConceeded,
                GoalsScored    = matchReport?.GoalsScored,
                Opponent       = matchReport?.Opponent,
                Scorers        = matchReport?.Scorers,
                ReportExists   = (eventReport != null && matchReport != null),
                Players        = GetSquadPlayersForEvent(@event)
            };

            return(View(model));
        }