コード例 #1
0
        private int AddGroup(GroupDTO group)
        {
            //translate the dto to the mp object
            var mpgroup = new MpGroup
            {
                Name                = @group.GroupName,
                GroupType           = @group.GroupTypeId,
                Full                = @group.GroupFullInd,
                WaitList            = @group.WaitListInd,
                WaitListGroupId     = @group.WaitListGroupId,
                PrimaryContactName  = @group.PrimaryContactName,
                PrimaryContactEmail = @group.PrimaryContactEmail,
                ChildCareAvailable  = @group.ChildCareAvailable,
                MinimumAge          = @group.MaximumAge,
                GroupDescription    = @group.GroupDescription,
                MinistryId          = @group.MinistryId,
                MeetingTime         = @group.MeetingTime,
                MeetingDayId        = @group.MeetingDayId,
                CongregationId      = @group.CongregationId,
                StartDate           = @group.StartDate,
                EndDate             = @group.EndDate,
                AvailableOnline     = @group.AvailableOnline,
                RemainingCapacity   = @group.RemainingCapacity,
                ContactId           = @group.ContactId,
                GroupRoleId         = @group.GroupRoleId,
                MaximumAge          = @group.MaximumAge,
                MinimumParticipants = @group.MinimumParticipants,
                TargetSize          = @group.TargetSize
            };

            return(_groupService.CreateGroup(mpgroup));
        }
コード例 #2
0
        public GroupDTO CreateGroup(GroupDTO group)
        {
            try
            {
                var mpGroup = Mapper.Map <MpGroup>(group);

                if (group.AttributeTypes.ContainsKey(_groupCategoryAttributeTypeId) && group.AttributeTypes[90].Attributes.Any(a => a.AttributeId == 0))
                {
                    var categoryAttributes = Mapper.Map <List <MpAttribute> >(group.AttributeTypes[90].Attributes);

                    categoryAttributes = _attributeService.CreateMissingAttributes(categoryAttributes, _groupCategoryAttributeTypeId);
                    group.AttributeTypes[_groupCategoryAttributeTypeId].Attributes = Mapper.Map <List <ObjectAttributeDTO> >(categoryAttributes);
                }

                group.GroupId = _mpGroupRepository.CreateGroup(mpGroup);
                //save group attributes
                var configuration = MpObjectAttributeConfigurationFactory.Group();
                _objectAttributeService.SaveObjectAttributes(group.GroupId, group.AttributeTypes, group.SingleAttributes, configuration);

                if (group.MinorAgeGroupsAdded)
                {
                    _mpGroupRepository.SendNewStudentMinistryGroupAlertEmail((List <MpGroupParticipant>)mpGroup.Participants);
                }
            }
            catch (Exception e)
            {
                var message = String.Format("Could not create group {0}", group.GroupName);
                _logger.Error(message, e);
                throw (new ApplicationException(message, e));
            }

            return(group);
        }