/// <summary> /// Used to link Slack Channel to OAuth Project - JJ /// </summary> /// <param name="slackChannelId">slack channel id from which message is send</param> /// <param name="givenProjectName">the project name mentioned in the slack message</param> /// <param name="project">OAuth Project of the given name</param> /// <returns>status message</returns> private async Task <string> LinkAsync(string slackChannelId, string givenProjectName, ProjectAc project) { if (project.IsActive) { SlackChannelDetails alreadyLinkedChannel = await _slackChannelRepository.FetchChannelByProjectIdAsync(project.Id); if (alreadyLinkedChannel == null) { //add the project id to the slack channel SlackChannelDetails slackChannel = await _slackChannelRepository.GetByIdAsync(slackChannelId); if (slackChannel.ProjectId == null) { _logger.Debug("\nLinkAsync method : not linked to any project yet\n"); slackChannel.ProjectId = project.Id; await _slackChannelRepository.UpdateSlackChannelAsync(slackChannel); return(string.Format(_stringConstant.ProjectLinked, givenProjectName, slackChannel.Name)); } else { return(string.Format(_stringConstant.UnLinkFirst, givenProjectName)); } } else { return(_stringConstant.AlreadyLinked); } } else { return(_stringConstant.InActiveProject); } }
public async Task FetchChannelByProjectIdAsync() { slackChannelDetails.ProjectId = 1; await _slackChannelRepository.AddSlackChannelAsync(slackChannelDetails); SlackChannelDetails slackChannel = await _slackChannelRepository.FetchChannelByProjectIdAsync((int)slackChannelDetails.ProjectId); Assert.Equal(slackChannel.Name, slackChannelDetails.Name); }