public async Task <TaskModuleResponse> Handle(Activity activity, IUrlHelper urlHelper) { var invokeActionData = activity.GetInvokeActionData(); var competition = await _competitionService.GetCompetition(invokeActionData.CompetitionId); var errorMessage = CanActivateCompetition(competition); if (!string.IsNullOrEmpty(errorMessage)) { return(_activityBuilder.CreateDraftCompetitionEditTaskInfoResponse(competition, errorMessage, activity.Locale)); } competition = await _competitionService.ActivateCompetition(competition.Id); var mainActivity = _activityBuilder.CreateMainActivity(competition); using (var botClient = _botClientFactory.CreateBotClient(activity.ServiceUrl)) { await botClient.UpdateActivityAsync(competition.ChannelId, competition.MainActivityId, mainActivity); } await _timerService.AddScheduledHttpRequest( competition.PlannedDrawTime, "POST", urlHelper.Action(nameof(CompetitionsController.DrawForCompetition), "Competitions", new { competitionId = competition.Id })); return(null); }
public async Task <TaskModuleResponse> Handle(Activity activity) { var invokeActionData = activity.GetInvokeActionData(); var competition = await _competitionService.GetCompetition(invokeActionData.CompetitionId); var canEdit = competition.CreatorAadObjectId == activity.From.AadObjectId; if (canEdit) { return(_activityBuilder.CreateDraftCompetitionEditTaskInfoResponse(competition, string.Empty, activity.Locale)); } else { return(_activityBuilder.CreateEditNotAllowedTaskInfoResponse(competition)); } }