private static async Task HandleReadNamedaysCommandAsync(VoiceCommandServiceConnection connection) { var userMessage = new VoiceCommandUserMessage(); userMessage.DisplayMessage = "Fetching today's namedays for you"; userMessage.SpokenMessage = "Fetching today's namedays for you"; var response = VoiceCommandResponse.CreateResponse(userMessage); await connection.ReportProgressAsync(response); var today = DateTime.Now.Date; var namedays = await NamedayRepository.GetAllNamedaysAsync(); var todaysNameday = namedays.Find(e => e.Day == today.Day && e.Month == today.Month); var namedaysAsString = todaysNameday.NamesAsString; if (todaysNameday.Names.Count() == 1) { userMessage.SpokenMessage = userMessage.DisplayMessage = $"It is { namedaysAsString}'s nameday today"; response = VoiceCommandResponse.CreateResponse(userMessage); } else { userMessage.SpokenMessage = $"Today's namedays are: {namedaysAsString}"; userMessage.DisplayMessage = "Here are today's namedays:"; var tile = new VoiceCommandContentTile(); tile.ContentTileType = VoiceCommandContentTileType.TitleOnly; tile.Title = namedaysAsString; response = VoiceCommandResponse.CreateResponse(userMessage, new List <VoiceCommandContentTile> { tile }); } await connection.ReportSuccessAsync(response); }
private static async Task HandleReadNamedaysCommandAsync(VoiceCommandServiceConnection connection) { var userMessage = new VoiceCommandUserMessage(); userMessage.DisplayMessage = "Je récupères les noms du jour pour vous"; userMessage.SpokenMessage = "Je récupères les noms du jour pour vous"; var response = VoiceCommandResponse.CreateResponse(userMessage); await connection.ReportProgressAsync(response); var today = DateTime.Now.Date; var namedays = await NamedayRepository.GetAllNamedaysAsync(); var todaysNamedays = namedays.Find(e => e.Day == today.Day && e.Month == today.Month); var namedaysAsString = todaysNamedays.NamesAsString; if (todaysNamedays.Names.Count() == 1) { userMessage.SpokenMessage = userMessage.DisplayMessage = $"Le nom du jour est {namedaysAsString}"; response = VoiceCommandResponse.CreateResponse(userMessage); } else { userMessage.SpokenMessage = $"Les noms du jour sont {namedaysAsString}"; userMessage.DisplayMessage = "Voici les noms du jour : "; var tile = new VoiceCommandContentTile(); tile.ContentTileType = VoiceCommandContentTileType.TitleOnly; tile.Title = namedaysAsString; response = VoiceCommandResponse.CreateResponse(userMessage, new List <VoiceCommandContentTile> { tile }); } await connection.ReportSuccessAsync(response); }