private void ExecuteAction(string action, Parameter[] parameters, Activity activity) { string username = activity.From.Name; if (action != "Update Address" && !DbController.AddressPopulated(activity.From.Name)) { AddToReplyQueue("Whoops. Looks like you need to update your address. Say \"update address\" to get started."); return; } switch (action) { case "Find Ride": // Notify all current drivers within N miles that person X needs a ride // // DirectMessages = DbController.GetNearbyDriverUsernames(username); AddToReplyQueue($"{DirectMessages.Count} nearby drivers were notified that you need a ride."); break; case "Update Address": var updatedAddress = parameters.Where(p => p.Name == "Address").FirstOrDefault()?.ParameterValues.FirstOrDefault().Entity; if (DbController.UpdateUserAddress(username, updatedAddress)) { AddToReplyQueue(updatedAddress.Count() > 0 ? $"Great! Your address has been updated to {updatedAddress}." : DbController.GetFailureMessage(action)); } else { AddToReplyQueue("Uh oh. Your address failed to update. Can you please try again in a few moments?"); } break; case "Become Driver": if (!DbController.IsDriver(username)) { DbController.BecomeDriver(username); AddToReplyQueue("You are now a driver! You'll be notified of nearby coworkers looking for rides. Thanks for being awesome."); } else { AddToReplyQueue("You are already a driver. If you'd like to no longer be a driver, say \"Stop being a driver.\""); } break; default: case "": break; } }