private static Handler GetHandler(Islaam.Database idb, string intent, IDictionary <string, object> entities) { if (intent == Intents.WHO_IS) { return(new WhoIsHandler(idb, entities)); } if (intent == Intents.GET_TEACHERS) { return(new GetTeachersHandler(idb, entities)); } if (intent == Intents.GET_STUDENTS) { return(new GetStudentsHandler(idb, entities)); } if (intent == Intents.GET_PRAISERS) { return(new GetPraisersHandler(idb, entities)); } if (intent == Intents.GET_PRAISEES) { return(new GetPraiseesHandler(idb, entities)); } if (intent == Intents.GET_DEATH_YEAR) { return(new GetDeathYearHandler(idb, entities)); } return(new NotSupportedHandler()); }
public GetPraisersHandler(Islaam.Database idb, IDictionary <string, object> entities) : base(idb, entities) { this.idb = idb; if (Person != null) { Person = idb .People .Include(p => p.PraisesReceived) .ThenInclude(x => x.Praiser) .ThenInclude(x => x.PraisesReceived) .ThenInclude(x => x.Praiser) .Include(p => p.PraisesReceived) .ThenInclude(x => x.Title) .ThenInclude(x => x.Status) .Where(p => p.Id == Person.Id) .FirstOrDefault(); praiserNames = Person .GetPraisesReceivedConsideringStatus() .Select(x => x.Praiser.Name) .Distinct() .ToList(); } }
public static async Task <IActionResult> Run( [HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route = null)] HttpRequest req ) { var idb = new Islaam.Database(); var requestBody = await new StreamReader(req.Body).ReadToEndAsync(); var fulfillmentRequest = JsonConvert.DeserializeObject <GoogleCloudDialogflowV2WebhookRequest>(requestBody); var intent = fulfillmentRequest.QueryResult.Intent.DisplayName; var entities = fulfillmentRequest.QueryResult.Parameters; var handler = GetHandler(idb, intent, entities); // if person found var response = new GoogleCloudDialogflowV2WebhookResponse { FulfillmentMessages = new List <GoogleCloudDialogflowV2IntentMessage> { // facebook new GoogleCloudDialogflowV2IntentMessage { Platform = "FACEBOOK", QuickReplies = new GoogleCloudDialogflowV2IntentMessageQuickReplies { QuickReplies = handler.QuickReplies, Title = handler.TextResponse }, }, // web new GoogleCloudDialogflowV2IntentMessage { Platform = null, Text = new GoogleCloudDialogflowV2IntentMessageText { Text = new List <string> { handler.TextResponse }, } }, } }; return(new OkObjectResult(response)); }
public GetTeachersHandler(Islaam.Database idb, IDictionary <string, object> entities) : base(idb, entities) { this.idb = idb; if (Person != null) { Person = idb .People .Include(p => p.Teachers) .Where(p => p.Id == Person.Id) .First(); teacherNames = Person .Teachers .Select(x => x.Teacher.Name) .Distinct() .ToList(); } }
public GetPraiseesHandler(Islaam.Database idb, IDictionary <string, object> entities) : base(idb, entities) { this.idb = idb; if (Person != null) { Person = idb .People .Include(p => p.PraisesGiven) .Where(p => p.Id == Person.Id) .First(); praiseeNames = Person .PraisesGiven .Select(x => x.Praisee.Name) .Distinct() .ToList(); } }
public GetDeathYearHandler(Islaam.Database idb, IDictionary <string, object> entities) : base(idb, entities) { }