Пример #1
0
        public Group UpdateGroup([FromBody] Group group)
        {
            var participant1  = _participantService.LoadParticipantById(group.Participant1Id);
            var participant2  = _participantService.LoadParticipantById(group.Participant2Id);
            var groupToUpdate = GroupConverter.ConvertDtoToModel(group, participant1, participant2);

            groupToUpdate = _groupService.Update(groupToUpdate);
            return(GroupConverter.ConvertModelToDto(groupToUpdate));
        }
Пример #2
0
        public Group AddGroup([FromBody] Group group)
        {
            var participant1 = _participantService.LoadParticipantById(group.Participant1Id);
            var participant2 = _participantService.LoadParticipantById(group.Participant2Id);
            var newGroup     = GroupConverter.ConvertDtoToModel(group, participant1, participant2);

            newGroup = _groupService.AddGroup(newGroup);
            return(GroupConverter.ConvertModelToDto(newGroup));
        }
Пример #3
0
        public IEnumerable <Group> GetAllAvailableGroups()
        {
            var allAvailableGroups = _groupService.LoadAllAvailableGroups();

            if (allAvailableGroups is null)
            {
                return(GroupConverter.ConvertModelToDto(new List <Model.Group>()));
            }

            return(GroupConverter.ConvertModelToDto(allAvailableGroups));
        }
Пример #4
0
        public IEnumerable <Group> GetAllGroupsOfRace()
        {
            if (string.IsNullOrEmpty(CurrentContext.CurrentRaceTitle))
            {
                return(new List <Group>());
            }

            var allGroups = _raceService.LoadCurrentRace().Groups;

            return(GroupConverter.ConvertModelToDto(allGroups));
        }
Пример #5
0
        public Group UpdateGroupToRace([FromBody] Group group)
        {
            var currentRace = _raceService.LoadCurrentRace();
            var oldGroup    = currentRace.Groups.SingleOrDefault(x => x.GroupId == group.GroupId);

            if (oldGroup is null)
            {
                return(null);
            }

            var groupToUpdate = GroupConverter.ConvertDtoToModel(group, oldGroup.Participant1, oldGroup.Participant2);

            _raceService.UpdateGroups(currentRace, groupToUpdate);
            return(GroupConverter.ConvertModelToDto(groupToUpdate));
        }