private void UpdateGroup(GroupDTO group) { //translate the dto to the mp object var mpgroup = new MpGroup { GroupId = @group.GroupId, 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 }; _groupService.UpdateGroup(mpgroup); }
public GroupDTO UpdateGroup(GroupDTO group) { try { var mpGroup = Mapper.Map <MpGroup>(group); _mpGroupRepository.UpdateGroup(mpGroup); List <MpGroupParticipant> groupParticipants = _mpGroupRepository.GetGroupParticipants(group.GroupId, true); if (groupParticipants.Count(participant => participant.StartDate < group.StartDate) > 0) { UpdateGroupParticipantStartDate(groupParticipants.Where(part => part.StartDate < group.StartDate).ToList(), group.StartDate); } 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); } var configuration = MpObjectAttributeConfigurationFactory.Group(); _objectAttributeService.SaveObjectAttributes(group.GroupId, group.AttributeTypes, group.SingleAttributes, configuration); if (group.MinorAgeGroupsAdded) { var leaders = groupParticipants.Where(p => p.GroupRoleId == _groupRoleLeader).ToList(); _mpGroupRepository.SendNewStudentMinistryGroupAlertEmail(leaders); } } catch (Exception e) { var message = String.Format("Could not update group {0}", group.GroupName); _logger.Error(message, e); throw (new ApplicationException(message, e)); } return(group); }