public IActionResult createReportedRaces(int id)
        {
            var    regatta      = _context.Regattas.FirstOrDefault(e => e.RegattaId == id);
            var    oldclasses   = _context.RegattaOldclasses.Include(e => e.Oldclasses).Where(e => e.RegattaId == id);
            var    competitions = _context.RegattaCompetitions.Include(e => e.Competitions).Where(e => e.RegattaId == id);
            string rc           = "00000E";

            foreach (var oc in oldclasses)
            {
                foreach (var c in competitions)
                {
                    if (!_context.ReportedRaces.Where(e => e.CompetitionId == c.CompetitionId && e.OldclassId == oc.OldclassId).Any())
                    {
                        var oldclass = _context.Oldclasses.FirstOrDefault(o => o.OldclassId == oc.OldclassId);
                        var comp     = _context.Competitions.Include(e => e.Raceclasses).Include(e => e.Boatclasses).FirstOrDefault(e => e.CompetitionId == c.CompetitionId);
                        rc = RaceCode.getRaceCode("M", comp, oldclass);
                        _context.ReportedRaces.Add(new ReportedRace {
                            OldclassId = oc.OldclassId, CompetitionId = c.CompetitionId, Gender = "M", RegattaId = id, RaceCode = rc
                        });
                        rc = RaceCode.getRaceCode("W", comp, oldclass);
                        _context.ReportedRaces.Add(new ReportedRace {
                            OldclassId = oc.OldclassId, CompetitionId = c.CompetitionId, Gender = "W", RegattaId = id, RaceCode = rc
                        });
                    }
                }
            }

            _context.SaveChanges();

            return(RedirectToAction("Index", "ReportedRaces"));
        }
 /// <summary>
 ///     Constructs a character to have specified properties.
 /// </summary>
 /// <param name="n">The character's name.</param>
 /// <param name="r">The character's race.</param>
 /// <param name="h">The character's height.</param>
 /// <param name="w">The character's weight.</param>
 /// <param name="id">The character's id.</param>
 /// <param name="position">The character's position.</param>
 /// <param name="rotation">The character's rotation.</param>
 /// <param name="regionid">The id of the region the character is on.</param>
 /// <param name="inventory">The dictionary of item ids to amounts that makes up the character's inventory.</param>
 public Character(string n, RaceCode r, short h, short w, Guid id, Vector3 position, Vector3 rotation, ushort regionid, Dictionary<ulong, int> inventory)
 {
     this.Name = n;
     this.Race = r;
     this.Height = h;
     this.Weight = w;
     this.Position = position;
     this.Rotation = rotation;
     this.Id = id;
     this.RegionId = regionid;
     this.Inventory = inventory;
 }
示例#3
0
        public async Task <IActionResult> Create([Bind("ReportedRaceId,OldclassId,CompetitionId,Gender,RegattaId,Comment")] ReportedRace reportedRace)
        {
            var competition = _context.Competitions.Include(e => e.Boatclasses).Include(e => e.Raceclasses).FirstOrDefault(e => e.CompetitionId == reportedRace.CompetitionId);
            var oldclass    = _context.Oldclasses.FirstOrDefault(e => e.OldclassId == reportedRace.OldclassId);

            if (ModelState.IsValid)
            {
                reportedRace.RaceCode = RaceCode.getRaceCode(reportedRace.Gender, competition, oldclass);

                _context.Add(reportedRace);

                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index), new { rid = reportedRace.RegattaId }));
            }
            ViewData["RegattaId"]     = new SelectList(_context.Regattas, "RegattaId", "Name", reportedRace.RegattaId);
            ViewData["CompetitionId"] = new SelectList(_context.Competitions, "CompetitionId", "Name", reportedRace.CompetitionId);
            ViewData["OldclassId"]    = new SelectList(_context.Oldclasses, "OldclassId", "Name", reportedRace.OldclassId);
            return(View(reportedRace));
        }