public GroupModel(GroupDTO group) : base(group) { this.cathedra = group.Cathedra; this.specialization = group.Specialization; this.cathedraId = group.CathedraID; this.specializationId = group.SpecializationID; }
private void CopyFromDTO(Group group, GroupDTO groupDTO) { group.Name = groupDTO.Name; }
public Task UpdateGroupAsync(GroupDTO groupDTO) { throw new NotImplementedException(); }
public void GroupTest() { var teamType1En = new team { abbreviation = "ABC", country = "Germany", id = "sr:team:1", name = "Team A", @virtual = true, virtualSpecified = true }; var teamType1De = new team { abbreviation = "ABC", country = "Deutschland", id = "sr:team:1", name = "Team A", @virtual = true, virtualSpecified = true }; var teamType2En = new team { abbreviation = "ABC", country = "Germany", id = "sr:team:2", name = "Team B", @virtual = true, virtualSpecified = true }; var teamType2De = new team { abbreviation = "ABC", country = "Deutschland", id = "sr:team:2", name = "Team B", @virtual = true, virtualSpecified = true }; var groupType1 = new tournamentGroup { name = "Group A", competitor = new[] { teamType1En, teamType2En } }; var groupType2 = new tournamentGroup { name = "Group A", competitor = new[] { teamType1De, teamType2De } }; var groupDTO1 = new GroupDTO(groupType1); var groupDTO2 = new GroupDTO(groupType2); var groupCI = new GroupCI(groupDTO1, _cultureFirst); groupCI.Merge(groupDTO2, _cultureSecond); Assert.IsNotNull(groupCI); Assert.AreEqual(groupType1.name, groupCI.Name); Assert.AreEqual(groupType1.competitor.Length, groupCI.CompetitorsIds.Count()); Assert.AreEqual(groupType1.competitor[0].id, groupCI.CompetitorsIds.ToList()[0].ToString()); Assert.AreEqual(groupType1.competitor[1].id, groupCI.CompetitorsIds.ToList()[1].ToString()); Assert.AreNotEqual(groupCI.CompetitorsIds.ToList()[0].Id, groupCI.CompetitorsIds.ToList()[1]); }
public ActionResult Post([FromBody] GroupDTO groupDTO) { GroupDTO group = this.groupService.Add(groupDTO); return(Ok(group)); }
public static Group Translate(GroupDTO group, List <GroupMemberDTO> members, DataTable staffing) { var slingshotGroup = new Group(); if (group.GroupId.HasValue) { slingshotGroup.Id = group.GroupId.Value; } else { if (!string.IsNullOrWhiteSpace(group.GroupName) && group.ParentGroupId.HasValue) { MD5 md5Hasher = MD5.Create(); string valueToHash = $"{ group.GroupName }{ group.ParentGroupId.Value }"; var hashed = md5Hasher.ComputeHash(Encoding.UTF8.GetBytes(valueToHash)); var groupId = Math.Abs(BitConverter.ToInt32(hashed, 0)); // used abs to ensure positive number if (groupId > 0) { slingshotGroup.Id = groupId; } } else { return(null); } } // Limit the group name to 50 since the schedules that will be created in Rock use the group's name as the schedule name and // that field is limited in the database to 50 characters slingshotGroup.Name = group.GroupName.Left(50); slingshotGroup.GroupTypeId = group.GroupTypeId; slingshotGroup.IsActive = group.IsActive; if (group.IsPublic.HasValue) { slingshotGroup.IsPublic = group.IsPublic.Value; } slingshotGroup.MeetingDay = group.ScheduleDay; slingshotGroup.ParentGroupId = group.ParentGroupId ?? 90000000 + slingshotGroup.GroupTypeId; slingshotGroup.Description = group.Description; if (!string.IsNullOrWhiteSpace(group.StartHour)) { slingshotGroup.MeetingTime = group.StartHour + ":00"; } var importAddress = new GroupAddress(); importAddress.GroupId = slingshotGroup.Id; importAddress.Street1 = group.Address1; importAddress.Street2 = group.Address2; importAddress.City = group.City; importAddress.State = group.StateProvince; importAddress.PostalCode = group.PostalCode; importAddress.Country = group.Country; importAddress.AddressType = AddressType.Other; // only add the address if we have a valid address if (importAddress.Street1.IsNotNullOrWhitespace() && importAddress.City.IsNotNullOrWhitespace() && importAddress.PostalCode.IsNotNullOrWhitespace()) { slingshotGroup.Addresses.Add(importAddress); } var groupMembers = members.AsEnumerable().Where(m => m.GroupId == slingshotGroup.Id); foreach (var member in groupMembers) { var groupMember = new GroupMember(); groupMember.GroupId = slingshotGroup.Id; groupMember.PersonId = member.IndividualId; groupMember.Role = member.GroupMemberType; slingshotGroup.GroupMembers.Add(groupMember); } if (staffing != null) { foreach (var staff in staffing.Select($"RLC_ID = { slingshotGroup.Id } OR Activity_ID = { slingshotGroup.Id }")) { var groupMember = new GroupMember(); groupMember.GroupId = slingshotGroup.Id; groupMember.PersonId = staff.Field <int>("INDIVIDUAL_ID"); groupMember.Role = "Staff"; slingshotGroup.GroupMembers.Add(groupMember); } } return(slingshotGroup); }
public GroupView(GroupDTO group) { InitializeComponent(); BindingContext = new GroupViewModel(group); }
public void DeleteGroup(GroupDTO group) { var deleteGroup = mapper.Map <Groups>(group); repoGroup.Delete(deleteGroup); }
public async Task <IList <GroupDTO> > GetGroupsAsync() { var groups = await this.groupRepository.GetAll().ToListAsync(); return(groups.Select(x => GroupDTO.FromEntity(x)).ToList()); }
public async Task <ActionResult> Add(GroupDTO groupDTO) { await _groupService.Create(groupDTO); return(Ok()); }
private static void Main() { var container = new UnityContainer(); var unitySections = new[] { "crossroadsCommonUnity", "unity" }; foreach (var section in unitySections.Select(sectionName => (UnityConfigurationSection)ConfigurationManager.GetSection(sectionName))) { container.LoadConfiguration(section); } TlsHelper.AllowTls12(); var eventService = container.Resolve <EventService>(); var groupService = container.Resolve <GroupService>(); var userApiService = container.Resolve <ApiUserRepository>(); var mpRestRepository = container.Resolve <MinistryPlatformRestRepository>(); // use childcare grouptype and eventtype var groupTypeId = Convert.ToInt32(ConfigurationManager.AppSettings["ChildcareGroupType"]); var eventTypeId = Convert.ToInt32(ConfigurationManager.AppSettings["ChildcareEventType"]); var defaultMinistryId = Convert.ToInt32(ConfigurationManager.AppSettings["ChildcareDefaultMinistryId"]); var configSettingsPageId = Convert.ToInt32(ConfigurationManager.AppSettings["ConfigurationSettingsPageId"]); try { //////////////////////////////////////////////////////////////////////// // Update the childcare events that are properly set up in a series //////////////////////////////////////////////////////////////////////// Log.Info("Updating Childcare events in series."); var apiToken = userApiService.GetToken(); AutoMapperConfig.RegisterMappings(); var parms = new Dictionary <string, object>() { { "@Group_Type", groupTypeId }, { "@Event_type", eventTypeId } }; //Call Andy's stored proc and loop through var results = mpRestRepository.UsingAuthenticationToken(apiToken).GetFromStoredProc <MpEventsMissingGroups>("api_crds_MissingChildcareGroup", parms); var eventList = results.FirstOrDefault() ?? new List <MpEventsMissingGroups>(); Log.Info("Updating " + eventList.Count.ToString() + " series events."); foreach (var item in eventList) { var groupdto = groupService.GetGroupDetails(item.GroupId); //change the date var mpevent = eventService.GetEvent(item.EventId); groupdto.StartDate = mpevent.EventStartDate; groupdto.Participants?.Clear(); groupdto.Events?.Clear(); groupdto.MeetingDayId = null; groupdto.MeetingFrequencyID = null; //change the dates var newgroupdto = groupService.CreateGroup(groupdto); //link the new group to the event eventService.AddEventGroup(item.EventId, newgroupdto.GroupId, apiToken); } //////////////////////////////////////////////////////////////////////// // Update the childcare events that are orphans (Use defaults) //////////////////////////////////////////////////////////////////////// //get default values 10,25,100 var maxAgeObject = MinistryPlatformService.GetRecordsDict(configSettingsPageId, apiToken, ",ChildcareMaxAge", string.Empty).FirstOrDefault()?["Value"]; var defaultMaximumAge = maxAgeObject != null?Convert.ToInt32(maxAgeObject) : 10; var minParticipantsObject = MinistryPlatformService.GetRecordsDict(configSettingsPageId, apiToken, ",ChildcareMinParticipants", string.Empty).FirstOrDefault()?["Value"]; var defaultMinimumParticipants = minParticipantsObject != null?Convert.ToInt32(minParticipantsObject) : 25; var targetSizeObject = MinistryPlatformService.GetRecordsDict(configSettingsPageId, apiToken, ",ChildcareTargetSize", string.Empty).FirstOrDefault()?["Value"]; var defaultTargetSize = targetSizeObject != null?Convert.ToInt32(targetSizeObject) : 100; Log.Info("Updating orphan Childcare events."); var orphanresults = mpRestRepository.UsingAuthenticationToken(apiToken).GetFromStoredProc <MpOrphanEventsMissingGroups>("api_crds_GetOrphanChildcareEvents", new Dictionary <string, object>()); var orphaneventList = orphanresults.FirstOrDefault() ?? new List <MpOrphanEventsMissingGroups>(); Log.Info("Updating " + eventList.Count.ToString() + " orphan events."); foreach (var item in orphaneventList) { var groupdto = new GroupDTO(); var mpevent = eventService.GetEvent(item.EventId); groupdto.StartDate = mpevent.EventStartDate; groupdto.Participants?.Clear(); groupdto.Events?.Clear(); groupdto.MeetingDayId = null; groupdto.MeetingFrequencyID = null; groupdto.CongregationId = mpevent.CongregationId; groupdto.Congregation = mpevent.Congregation; groupdto.ContactId = mpevent.PrimaryContact.ContactId; groupdto.MaximumAge = defaultMaximumAge; groupdto.MinimumParticipants = defaultMinimumParticipants; groupdto.TargetSize = defaultTargetSize; groupdto.GroupName = "__childcaregroup"; groupdto.GroupTypeId = groupTypeId; groupdto.MinistryId = defaultMinistryId; var newgroupdto = groupService.CreateGroup(groupdto); //link the new group to the event eventService.AddEventGroup(item.EventId, newgroupdto.GroupId, apiToken); } Log.Info("Childcare Group update Complete."); } catch (Exception ex) { Log.Error("Childcare Group Update Notifcation Failed", ex); Environment.Exit(9999); } Environment.Exit(0); }
public void EditGroup(GroupDTO group, ICollection <GroupDTO> selectedGroups, ICollection <UserDTO> selectedUsers) { if (group.GroupName != null) { Group groupToEdit = _groups.FindById(group.GroupId); if (group.GroupName != null && group.GroupName != groupToEdit.GroupName) { groupToEdit.GroupName = group.GroupName; } if (group.ParentId != groupToEdit.ParentId) { groupToEdit.ParentId = group.ParentId; } ICollection <User> usersFromBranches = GetGroupUsersFromBranches(groupToEdit.GroupId); if (selectedUsers.Any()) { var convertUsers = new List <User>(); if (selectedUsers != null) { var convert = Mapper.Map <IEnumerable <UserDTO>, ICollection <User> >(selectedUsers); foreach (var item in convert) { if (_users.FindById(item.UserId) != null) { convertUsers.Add(_users.FindById(item.UserId)); } } } groupToEdit.Users = groupToEdit.Users.Intersect(convertUsers).ToList(); foreach (var oldUser in usersFromBranches.ToList()) { foreach (var user in selectedUsers.ToList()) { if (user.UserId == oldUser.UserId) { usersFromBranches.Remove(oldUser); selectedUsers.Remove(user); } } } if (usersFromBranches.Any()) { DeleteUsersFromBranch(usersFromBranches, groupToEdit.GroupId); } if (selectedUsers.Any()) { foreach (var item in selectedUsers.ToList()) { groupToEdit.Users.Add(_users.FindById(item.UserId)); } } } else { foreach (var item in groupToEdit.Users.ToList()) { groupToEdit.Users.Remove(_users.FindById(item.UserId)); } if (usersFromBranches.Any()) { DeleteUsersFromBranch(usersFromBranches, groupToEdit.GroupId); } } ICollection <Group> oldGroups = _groups.Get(g => g.ParentId == groupToEdit.GroupId).ToList(); foreach (var item in oldGroups.ToList()) { foreach (var temp in selectedGroups.ToList()) { if (item.GroupId == temp.GroupId) { oldGroups.Remove(item); selectedGroups.Remove(temp); } } } if (oldGroups.Any()) { foreach (var item in oldGroups) { var temp = _groups.FindById(item.GroupId); temp.ParentId = null; } } if (selectedGroups.Any()) { var convertGroups = new List <Group>(); if (selectedGroups != null) { var convert = Mapper.Map <IEnumerable <GroupDTO>, IEnumerable <Group> >(selectedGroups); foreach (var item in convert) { if (_groups.FindById(item.GroupId) != null) { convertGroups.Add(_groups.FindById(item.GroupId)); } } } foreach (var item in convertGroups) { item.ParentId = groupToEdit.GroupId; } } _context.SaveChanges(); foreach (var id in usersFromBranches.Select(u => u.UserId)) { _context.Entry(_users.FindById(id)).State = System.Data.Entity.EntityState.Detached; } } }
public void CancelGroup(GroupDTO data, bool ISCANCEL) { service.CancelGroup(data, ISCANCEL); }
public int SaveGroup(GroupDTO data) { return(service.SaveGroup(data)); }
public GroupDTO getGroupDetails(int groupId, int contactId, MpParticipant participant, string authUserToken) { int participantId = participant.ParticipantId; MpGroup g = _mpGroupRepository.getGroupDetails(groupId); var signupRelations = _mpGroupRepository.GetGroupSignupRelations(g.GroupType); var currRelationships = _contactRelationshipService.GetMyCurrentRelationships(contactId, authUserToken); var events = _mpGroupRepository.getAllEventsForGroup(groupId); MpContactRelationship[] familyToReturn = null; if (currRelationships != null) { familyToReturn = currRelationships.Where( c => signupRelations.Select(s => s.RelationshipId).Contains(c.Relationship_Id)).ToArray(); } var apiToken = _apiUserService.GetToken(); var configuration = MpObjectAttributeConfigurationFactory.Group(); var attributesTypes = _objectAttributeService.GetObjectAttributes(apiToken, groupId, configuration); var detail = new GroupDTO(); { detail.ContactId = g.ContactId; detail.CongregationId = g.CongregationId; detail.KidsWelcome = g.KidsWelcome; detail.GroupName = g.Name; detail.GroupDescription = g.GroupDescription; detail.GroupId = g.GroupId; detail.GroupFullInd = g.Full; detail.WaitListInd = g.WaitList ?? false; detail.ChildCareAvailable = g.ChildCareAvailable; detail.WaitListGroupId = g.WaitListGroupId; detail.OnlineRsvpMinimumAge = g.MinimumAge; detail.MeetingFrequencyID = g.MeetingFrequencyID; detail.AvailableOnline = g.AvailableOnline; detail.MeetingTime = g.MeetingTime; detail.MeetingDayId = g.MeetingDayId; detail.Address = Mapper.Map <MpAddress, AddressDTO>(g.Address); detail.StartDate = g.StartDate; detail.Participants = (g.Participants.Count > 0) ? g.Participants.Select(p => Mapper.Map <MpGroupParticipant, GroupParticipantDTO>(p)).ToList() : null; if (events != null) { detail.Events = events.Select(Mapper.Map <MpEvent, Event>).ToList(); } //the first instance of family must always be the logged in user var fam = new SignUpFamilyMembers { EmailAddress = participant.EmailAddress, PreferredName = participant.PreferredName, UserInGroup = _mpGroupRepository.checkIfUserInGroup(participantId, g.Participants), ParticpantId = participantId, ChildCareNeeded = false }; detail.SignUpFamilyMembers = new List <SignUpFamilyMembers> { fam }; if (familyToReturn != null) { foreach (var f in familyToReturn) { var fm = new SignUpFamilyMembers { EmailAddress = f.Email_Address, PreferredName = f.Preferred_Name, UserInGroup = _mpGroupRepository.checkIfUserInGroup(f.Participant_Id, g.Participants), ParticpantId = f.Participant_Id, }; detail.SignUpFamilyMembers.Add(fm); } } detail.AttributeTypes = attributesTypes.MultiSelect; detail.SingleAttributes = attributesTypes.SingleSelect; } return(detail); }
public void AddGroup(GroupDTO group) { var addGroup = mapper.Map <Groups>(group); repoGroup.Create(addGroup); }
private void UpdateGroupModel(GroupModel groupModel, GroupDTO groupDTO) { groupModel.Name = groupDTO.Name; groupModel.DefaultCurrency = groupDTO.DefaultCurrency; }
public void UpdateGroup(GroupDTO group) { throw new NotImplementedException(); }
public bool GroupCreate(GroupDTO groupC) { GroupCRUD group = new GroupCRUD(); return(group.Add(groupC)); }
public ActionResult CreateGroup(GroupsViewModel groupViewModel) { this.logger.Info("Entering: " + System.Reflection.MethodBase.GetCurrentMethod().ReflectedType.FullName + ": " + System.Reflection.MethodBase.GetCurrentMethod().Name + " --> " + User.Identity.Name); try { var groupType = Request["groupType"]; if (groupType != null && !groupType.Equals("")) { var _userId = Session["UserId"]; var _sessionUser = Convert.ToInt32(_userId); Groups group = new Groups(); #region create new group //create the dto for the new group GroupDTO dto = new GroupDTO(); dto.GroupDescription = groupViewModel.GroupDescription; dto.GroupName = groupViewModel.GroupName; dto.GroupType = groupViewModel.GroupType; dto.OwnerId = _sessionUser; using (var client = new HttpClient()) { client.BaseAddress = new Uri(this.apiMethodsUrl); client.DefaultRequestHeaders.Accept.Add( new MediaTypeWithQualityHeaderValue("application/json") ); HttpResponseMessage response = client.PostAsJsonAsync("api/groups/AddGroup/?group=", dto).Result; if (response.IsSuccessStatusCode) { var g = response.Content.ReadAsAsync <Groups>().Result; if (g != null) { group.GroupDescription = g.GroupDescription; group.GroupId = g.GroupId; group.GroupName = g.GroupName; group.GroupType = g.GroupType; group.OwnerId = g.OwnerId; } else { throw new CustomException("Could not complete the operation!"); } } else { throw new CustomException("Could not complete the operation!"); } } #endregion #region subscribe to created group //create dto for the new member GroupMemberDTO dto1 = new GroupMemberDTO(); dto1.GroupId = group.GroupId; dto1.MemberId = _sessionUser; using (var client = new HttpClient()) { client.BaseAddress = new Uri(this.apiMethodsUrl); client.DefaultRequestHeaders.Accept.Add( new MediaTypeWithQualityHeaderValue("application/json") ); HttpResponseMessage response = client.PostAsJsonAsync("api/groups/AddGroupMember/?groupMember=", dto1).Result; if (!response.IsSuccessStatusCode) { throw new CustomException("Could not complete the operation!"); } } #endregion return(RedirectToAction("DisplayAssociatedGroups")); } else { this.logger.Trace("Username: "******"Please choose a type for the group!"; return(View("Error")); } } catch (CustomException ce) { this.logger.Trace(ce, "Username: "******"Operation could not be completed! Try again."; return(View("Error")); } catch (Exception ex) { this.logger.Trace(ex, "Username: "******"Operation could not be completed!"; return(View("Error")); } }
public bool GroupUpdate(GroupDTO groupU) { GroupCRUD group = new GroupCRUD(); return(group.Update(groupU)); }
public async static Task <ApiResult <string> > CreateGroup(GroupDTO groupDTO) => await new ApiRequest <string>().Invoke("groups", Method.Post, groupDTO);
public async Task <ActionResult> Get(int id) { GroupDTO groupDTO = await _groupService.Get(id); return(Ok(_mapper.Map <GroupModel>(groupDTO))); }
public ActionResult Put([FromBody] GroupDTO groupDTO) { GroupDTO group = this.groupService.Update(groupDTO); return(Ok(group)); }
public void SendGroupParticipantEmail(int groupId, GroupDTO group, int emailTemplateId, MpParticipant toParticipant, string subjectTemplateContentBlockTitle = null, string emailTemplateContentBlockTitle = null, string message = null, MpParticipant fromParticipant = null) { var participant = new GroupParticipantDTO { ContactId = toParticipant.ContactId, Email = toParticipant.EmailAddress, NickName = toParticipant.PreferredName, ParticipantId = toParticipant.ParticipantId }; var emailTemplate = _communicationRepository.GetTemplate(emailTemplateId); var fromContact = new MpContact { ContactId = emailTemplate.FromContactId, EmailAddress = emailTemplate.FromEmailAddress }; var replyTo = new MpContact { ContactId = fromParticipant?.ContactId ?? emailTemplate.ReplyToContactId, EmailAddress = fromParticipant == null ? emailTemplate.ReplyToEmailAddress : fromParticipant.EmailAddress }; var leader = _contactRepository.GetContactById(replyTo.ContactId); var to = new List <MpContact> { new MpContact { ContactId = participant.ContactId, EmailAddress = participant.Email } }; var subjectTemplateText = string.IsNullOrWhiteSpace(subjectTemplateContentBlockTitle) ? string.Empty : _contentBlockService[subjectTemplateContentBlockTitle].Content ?? string.Empty; var emailTemplateText = string.IsNullOrWhiteSpace(emailTemplateContentBlockTitle) ? string.Empty : _contentBlockService[emailTemplateContentBlockTitle].Content; var mergeData = getDictionary(participant); mergeData["Email_Custom_Message"] = string.IsNullOrWhiteSpace(message) ? string.Empty : message; mergeData["Group_Name"] = group.GroupName; mergeData["Group_Description"] = group.GroupDescription; mergeData["Leader_Name"] = leader.Nickname != null && leader.Last_Name != null ? leader.Nickname + " " + leader.Last_Name : replyTo.EmailAddress; mergeData["City"] = group.Address.City; mergeData["State"] = group.Address.State; if (fromParticipant != null) { mergeData["From_Display_Name"] = fromParticipant.DisplayName; mergeData["From_Preferred_Name"] = fromParticipant.PreferredName; } // Since the templates are coming from content blocks, they may have replacement tokens in them as well. // These will not get replaced with merge data in _communicationRepository.SendMessage(), (it doesn't doubly // replace) so we'll parse them here before adding them to the merge data. mergeData["Subject_Template_Text"] = _communicationRepository.ParseTemplateBody(Regex.Replace(subjectTemplateText, "<.*?>", string.Empty), mergeData); mergeData["Email_Template_Text"] = _communicationRepository.ParseTemplateBody(emailTemplateText, mergeData); var email = new MpCommunication { EmailBody = emailTemplate.Body, EmailSubject = emailTemplate.Subject, AuthorUserId = _emailAuthorId, DomainId = _domainId, FromContact = fromContact, ReplyToContact = replyTo, TemplateId = emailTemplateId, ToContacts = to, MergeData = mergeData }; _communicationRepository.SendMessage(email); }
public async Task <int?> GetMentorIdByGroupAsync(int groupId) { GroupDTO group = await GetGroupByIdAsync(groupId); return(group?.MentorId); }
public bool ValidateUserAsLeader(string token, int groupTypeId, int groupId, int groupParticipantId, GroupDTO group) { var groupParticipants = group.Participants; var me = _participantRepository.GetParticipantRecord(token); if (groupParticipants == null || groupParticipants.Find(p => p.ParticipantId == me.ParticipantId) == null) { throw new NotGroupLeaderException($"Group participant {groupParticipantId} is not a leader of group {groupId}"); } var isLeader = false; foreach (var part in groupParticipants) { if ((me.ParticipantId == part.ParticipantId) && (_groupRoleLeaderId == part.GroupRoleId)) { isLeader = true; break; } } return(isLeader); }
public GroupModel(string group_id) { groupDTO = groupProvider.getGroup(group_id).Result; groupUsers = groupProvider.getGroupMembers(group_id).Result; }
public void PostStatusToGroup(StatusDTO statusDTO, GroupDTO groupDTO) { statusService.PostStatusToGroup(statusDTO, groupDTO); }
public bool AddUpdateGroup([FromBody] GroupDTO dto) { return(_dataAPI.AddUpdateGroup(dto)); }
public async Task InsertGroup(GroupDTO gr) { await _unitofWork.GroupRepository.InsertGroup(gr); }