Exemple #1
0
        private void AddGroup(string[] input)
        {
            if (string.IsNullOrEmpty(CurrentContext.CurrentRaceTitle))
            {
                logger.Info($"No race created yet");
                return;
            }

            var currentGroups   = _raceService.LoadCurrentRace().Groups.ToList();
            var availableGroups = _groupService.LoadAllAvailableGroups();

            foreach (var groupIdentifier in input)
            {
                int.TryParse(groupIdentifier, out int startNumber);
                var group = availableGroups.SingleOrDefault(x => x.Groupname == groupIdentifier || x.StartNumber == startNumber);

                if (group == null)
                {
                    logger.Info($"Unable to find group {groupIdentifier}");
                    return;
                }

                if (currentGroups.Contains(group))
                {
                    logger.Info($"Group {groupIdentifier} is already part of this race");
                    continue;
                }

                _raceService.AddGroup(group);

                logger.Info($"Group {groupIdentifier} successfully added to race");
            }
        }
Exemple #2
0
        public Group AddGroupToRace([FromBody] Group group)
        {
            var participant1 = _participantService.LoadParticipantById(group.Participant1Id);
            var participant2 = _participantService.LoadParticipantById(group.Participant2Id);
            var newGroup     = GroupConverter.ConvertDtoToModel(group, participant1, participant2);

            _raceService.AddGroup(newGroup);

            return(GroupConverter.ConvertModelToDto(newGroup));
        }