public async Task <ActionResult> SaveOrUpdateTask(TaskInfo taskInfo) { var userList = await DBHelper.GetListOfUser(_configuration); var allUser = await DBHelper.GetUserDataDictionaryAsync(_configuration); var name = userList.Where(e => e.Value == taskInfo.userName).Select(e => e.Text).FirstOrDefault(); taskInfo.taskCreatedBy = name; taskInfo.taskCreatedByEmail = taskInfo.userName; taskInfo.allDependentTaskIDs = await _taskDataRepository.GetAllTaskIDsAndTitles(taskInfo.dependentOn); taskInfo.allBlocksTaskIDs = await _taskDataRepository.GetAllTaskIDsAndTitles(taskInfo.blocks); CardHelper cardhelper = new CardHelper(_configuration); var attPath = taskInfo.attachements; await DBHelper.SaveTaskInfo(taskInfo, _configuration); var adaptiveCard = cardhelper.TaskInformationCard(taskInfo); var cardAttachment = new Attachment() { ContentType = AdaptiveCard.ContentType, Content = adaptiveCard, }; var recipietSet = new HashSet <string>(); foreach (var item in taskInfo.subscribers) { recipietSet.Add(item); } recipietSet.Add(taskInfo.taskAssignedTo); recipietSet.Add(taskInfo.taskCreatedByEmail); foreach (var recipient in recipietSet) { if (allUser.ContainsKey(recipient)) { await Common.SendNotificationAsync(_configuration, cardAttachment, allUser[recipient]); } } return(View(taskInfo)); }
protected override async Task <TaskModuleResponse> OnTeamsTaskModuleSubmitAsync(ITurnContext <IInvokeActivity> turnContext, TaskModuleRequest taskModuleRequest, CancellationToken cancellationToken) { TaskInfo taskInfo; try { taskInfo = JsonConvert.DeserializeObject <TaskInfo>(taskModuleRequest.Data.ToString()); } catch (Exception e) { throw; } switch (taskInfo.action) { case "Depends on": case "Blocks": case "updateAdaptiveCard": try { var name = (turnContext.Activity.From.Name).Split(); taskInfo.taskCreatedBy = name[0] + ' ' + name[1]; List <string> emailids = new List <string>(); taskInfo.taskCreatedByEmail = await DBHelper.GetUserEmailId(turnContext); taskInfo.allDependentTaskIDs = await _taskDataRepository.GetAllTaskIDsAndTitles(taskInfo.dependentOn); taskInfo.allBlocksTaskIDs = await _taskDataRepository.GetAllTaskIDsAndTitles(taskInfo.blocks); await DBHelper.SaveTaskInfo(taskInfo, _configuration); var typingActivity = MessageFactory.Text(string.Empty); typingActivity.Type = ActivityTypes.Typing; await turnContext.SendActivityAsync(typingActivity); var adaptiveCard = _cardHelper.TaskInformationCard(taskInfo); foreach (var email in taskInfo.subscribers) { await Common.SendNotification(turnContext, cancellationToken, _configuration, email, adaptiveCard); } if (taskInfo.taskAssignedTo != taskInfo.taskCreatedByEmail) { await Common.SendNotification(turnContext, cancellationToken, _configuration, taskInfo.taskCreatedByEmail, adaptiveCard); } var reply = MessageFactory.Attachment(new Attachment { ContentType = AdaptiveCard.ContentType, Content = adaptiveCard }); var result = await turnContext.SendActivityAsync(reply, cancellationToken); reply.Id = "1594196918362"; } catch (Exception e) { throw; } return(null); default: return(null); } }