Beispiel #1
0
        public IActionResult OnPostEnterTeam([FromBody] AddTeamRequest addTeamRequest)
        {
            try
            {
                if (addTeamRequest.RaceId == 0)
                {
                    throw new Exception("Invalid Race");
                }

                var teamId = GetNextTeamId(addTeamRequest.RaceId);

                foreach (int racerId in addTeamRequest.RacerIds)
                {
                    var result = new WLC.Models.Results()
                    {
                        Place   = 4,
                        TeamId  = teamId,
                        RaceId  = addTeamRequest.RaceId,
                        RacerId = racerId,
                        Year    = Globals.GetActiveYear(HttpContext)
                    };
                    _context.Results.Add(result);
                }
                _context.SaveChanges();
                return(new JsonResult(new { error = false, message = "RacerAdded" }));
            }
            catch (Exception ex)
            {
                return(new JsonResult(new { error = true, message = "Adding Team Failed: " + ex.Message }));
            }
        }
Beispiel #2
0
        public IActionResult OnGetEnterRacer([FromQuery] int racerId, int raceId)
        {
            try
            {
                if (racerId == 0)
                {
                    throw new Exception("Invalid Race");
                }

                var result = new WLC.Models.Results()
                {
                    Place   = 4,
                    TeamId  = GetNextTeamId(raceId),
                    RaceId  = raceId,
                    RacerId = racerId,
                    Year    = Globals.GetActiveYear(HttpContext)
                };
                _context.Results.Add(result);
                _context.SaveChanges();
                return(new JsonResult(new { error = false, message = "RacerAdded" }));
            }
            catch (Exception ex)
            {
                return(new JsonResult(new { error = true, message = "Adding Racer Failed: " + ex.Message }));
            }
        }