// Find a fixed conversational rule by Id public FixedConversationalRule FindFixedConversationalRuleById(string id) { FixedConversationalRule newRule; try { var x = fixedConversationalRuleTableAdapter.FindFixedConversationalRuleById(id).ToList().First(); newRule = new FixedConversationalRule(x.Id, x.Input, x.Output, x.RelatedUsersId, Utils.GetStatus(x.Status)); } catch { newRule = null; } return newRule; }
// Find fixed conversational rules by status public List<FixedConversationalRule> FindFixedConversationalRulesAccordingToStatus(Status status) { List<FixedConversationalRule> result = new List<FixedConversationalRule>(); foreach (var x in fixedConversationalRuleTableAdapter.GetAllFCRulesByStatus(status.ToString()).ToList()) { string id = x.Id; string input = x.Input; string output = x.Output; string relatedUserId = x.RelatedUsersId; FixedConversationalRule conversationalRule = new FixedConversationalRule(id, input, output, relatedUserId, status); result.Add(conversationalRule); } return result; }
// Add a fixed conversation rule public void AddNewFCRule(string input, string output, string userId) { FixedConversationalRule rule = new FixedConversationalRule(Utils.CreateIdByType("FixedConversationalRule", dataHandler.FindLastFixedConversationalRuleId()), Utils.IgnoreWhiteSpace(input), Utils.IgnoreWhiteSpace(output), userId, Status.Pending); dataHandler.AddFixedConversationalRule(rule); }