public void addParticipantToGroupNoEvents(int groupId, ParticipantSignup participant) { MpGroup group; try { group = _mpGroupRepository.getGroupDetails(groupId); } catch (Exception e) { var message = String.Format("Could not retrieve group details for group {0}: {1}", groupId, e.Message); _logger.Error(message, e); throw (new ApplicationException(message, e)); } checkSpaceRemaining(new List <ParticipantSignup> { participant }, group); try { var roleId = participant.groupRoleId ?? _groupRoleDefaultId; var participantId = participant.particpantId.Value; var groupParticipantId = _mpGroupRepository.addParticipantToGroup(participantId, Convert.ToInt32(groupId), roleId, participant.childCareNeeded, DateTime.Now, null, false, participant.EnrolledBy); var configuration = MpObjectAttributeConfigurationFactory.GroupParticipant(); _objectAttributeService.SaveObjectAttributes(groupParticipantId, participant.AttributeTypes, participant.SingleAttributes, configuration); if (participant.capacityNeeded > 0) { DecrementCapacity(participant.capacityNeeded, group); } } catch (Exception e) { _logger.Error("Could not add user to group", e); throw; } }
public void RegisterForEvent(EventRsvpDto eventDto, string token) { var defaultGroupRoleId = AppSetting("Group_Role_Default_ID"); var today = DateTime.Today; try { var saved = eventDto.Participants.Select(participant => { var groupParticipantId = _groupParticipantService.Get(eventDto.GroupId, participant.ParticipantId); if (groupParticipantId == 0) { groupParticipantId = _groupService.addParticipantToGroup(participant.ParticipantId, eventDto.GroupId, defaultGroupRoleId, participant.ChildcareRequested, today); } // validate that there is not a participant record before creating var retVal = Functions.IntegerReturnValue( () => !_eventService.EventHasParticipant(eventDto.EventId, participant.ParticipantId) ? _eventService.RegisterParticipantForEvent(participant.ParticipantId, eventDto.EventId, eventDto.GroupId, groupParticipantId) : 1); return(new RegisterEventObj() { EventId = eventDto.EventId, ParticipantId = participant.ParticipantId, RegisterResult = retVal, ChildcareRequested = participant.ChildcareRequested }); }).ToList(); SendRsvpMessage(saved, token); } catch (Exception e) { throw new ApplicationException("Unable to add event participant: " + e.Message); } }