/// <summary> /// Updates the AgentGroupMembers of the specified AgentGroup id /// </summary> /// <param name="agentGroupId"></param> /// <param name="agentId"></param> /// <returns></returns> public IEnumerable <AgentGroupMember> UpdateGroupMembers(string agentGroupId, IEnumerable <AgentGroupMember> groupMembers) { var agentGroupGuid = Guid.Parse(agentGroupId); AgentGroup agentGroup = _agentGroupRepository.GetOne(agentGroupGuid); if (agentGroup == null) { throw new EntityDoesNotExistException("No agent group was found with the specified id"); } List <AgentGroupMember> memberList = new List <AgentGroupMember>(); DeleteGroupMembers(agentGroupId);//delete existing members foreach (var member in groupMembers ?? Enumerable.Empty <AgentGroupMember>()) { member.AgentGroupId = agentGroupGuid; member.CreatedBy = _caller.Identity.Name; member.CreatedOn = DateTime.UtcNow; _agentGroupMemberRepository.Add(member); memberList.Add(member); } _webhookPublisher.PublishAsync("AgentGroups.AgentGroupMemberUpdated", agentGroupId, agentGroup.Name).ConfigureAwait(false); return(memberList.AsEnumerable()); }
public async Task <IActionResult> Patch(string id, [FromBody] JsonPatchDocument <AgentGroup> request) { try { Guid entityId = new Guid(id); var existingAgentGroup = _agentGroupRepository.GetOne(entityId); if (existingAgentGroup == null) { throw new EntityDoesNotExistException("No agent group exists with the specified id"); } _agentGroupsManager.AttemptPatchUpdate(request, entityId); var result = await base.PatchEntity(id, request); await _webhookPublisher.PublishAsync("AgentGroups.AgentGroupUpdated", existingAgentGroup.Id.ToString(), existingAgentGroup.Name).ConfigureAwait(false); return(result); } catch (Exception ex) { return(ex.GetActionResult()); } }
public JobViewModel GetJobView(JobViewModel jobView) { jobView.AgentName = _agentRepo.GetOne(jobView.AgentId ?? Guid.Empty)?.Name; jobView.AgentGroupName = _agentGroupRepository.GetOne(jobView.AgentGroupId ?? Guid.Empty)?.Name; jobView.AutomationName = _automationRepo.GetOne(jobView.AutomationId ?? Guid.Empty)?.Name; jobView.JobParameters = GetJobParameters(jobView.Id ?? Guid.Empty); return(jobView); }
public ScheduleViewModel GetScheduleViewModel(ScheduleViewModel scheduleView) { scheduleView.AgentName = _agentRepository.GetOne(scheduleView.AgentId ?? Guid.Empty)?.Name; scheduleView.AgentGroupName = _agentGroupRepository.GetOne(scheduleView.AgentGroupId ?? Guid.Empty)?.Name; scheduleView.AutomationName = _automationRepository.GetOne(scheduleView.AutomationId ?? Guid.Empty)?.Name; scheduleView.ScheduleParameters = GetScheduleParameters(scheduleView.Id ?? Guid.Empty); return(scheduleView); }