public IHttpActionResult GetToken(int id) { using (var context = new TokensContext()) { var product = context.Tokens.Find(id); if (product == null) { return NotFound(); } return Ok(product); } }
public IEnumerable<Object> GetTokenSet(string sc = "", int ti = 10) { using (TokensContext myEntities = new TokensContext()) { //*create a list of selected categories //*use this list in the where clause of the query string selectedCategories = sc; List<int> selCatsList = new List<int>(); StringBuilder selCatsStr = new StringBuilder(selectedCategories); for (int i = 0; i < selCatsStr.Length; i++) { if (selCatsStr[i] == '1') selCatsList.Add(i + 1); } //get tokens from db into an array. var tempTokens1 = (from token in myEntities.Tokens where selCatsList.Contains(token.CategoryId) select new { token.Id, token.CategoryId, token.Name, token.ImageSource, token.ItemText }).ToArray(); int resultLen = tempTokens1.Length; int numItems = ti; if (resultLen > numItems) //if (selected count > number of items requested) { //then pick numItems entries randomly from the result Random rnd = new Random(); //get a random number generator for selection Object[] tempList = new Object[numItems]; int item, lastIndex = resultLen - 1; for (int i = 0; i < numItems; i++, lastIndex--) { item = rnd.Next(0, lastIndex); //get a random index within the query result tempList[i] = tempTokens1[item]; //add item to result list tempTokens1[item] = tempTokens1[lastIndex]; //move end query item to this spot lastIndex--; //shorten range for next random index } return tempList; //return the list of selections from the query result } else { return tempTokens1; //return the query result } } }
/// <summary> /// Method to make a review with the choice of the end user /// </summary> /// <param name="configuration">The configuration get from appsettings</param> /// <param name="httpClientFactory">The Http client to make a request to QaNMaker</param> public ReviewSelectionDialog(IConfiguration configuration, IHttpClientFactory httpClientFactory, TokensContext _tokensContext) : base(nameof(ReviewSelectionDialog)) { client = new HttpClient { BaseAddress = new Uri(configuration["HostHttpAPI"]) }; client.DefaultRequestHeaders.Accept.Clear(); client.DefaultRequestHeaders.Accept.Add( new MediaTypeWithQualityHeaderValue("application/json")); _configuration = configuration; tokensContext = _tokensContext; _httpClientFactory = httpClientFactory; AddDialog(new ChoicePrompt(nameof(ChoicePrompt))); AddDialog(new WaterfallDialog(nameof(WaterfallDialog), new WaterfallStep[] { QuestionStepAsync, SelectionStepAsync, LoopStepAsync, })); InitialDialogId = nameof(WaterfallDialog); }
public ConnectController(TokensContext tokens, IOptions <OAuth2Keys> auth2Keys) { _tokens = tokens; _auth2Keys = auth2Keys.Value; }
public ConnectController(IOptions <OAuth2Keys> oAuth2Keys, IServices services, TokensContext tokens) { _oAuth2Keys = oAuth2Keys.Value; _services = services; _tokens = tokens; }
public MainDialog(UserState userState, IConfiguration configuration, IHttpClientFactory httpClientFactory, TokensContext _tokensContext) : base(nameof(MainDialog)) { _userState = userState; AddDialog(new TopLevelDialog(configuration, httpClientFactory, _tokensContext)); AddDialog(new WaterfallDialog(nameof(WaterfallDialog), new WaterfallStep[] { InitialStepAsync, FinalStepAsync, })); InitialDialogId = nameof(WaterfallDialog); }
public TokensController(TokensContext _db) { db = _db; }
public TokensController(TokensContext context) { _context = context; }
public TopLevelDialog(IConfiguration configuration, IHttpClientFactory httpClientFactory, TokensContext _tokensContext) : base(nameof(TopLevelDialog)) { AddDialog(new TextPrompt(nameof(TextPrompt))); AddDialog(new ReviewSelectionDialog(configuration, httpClientFactory, _tokensContext)); AddDialog(new WaterfallDialog(nameof(WaterfallDialog), new WaterfallStep[] { StartQuestionStepAsync, EndQuestionStepAsync, })); InitialDialogId = nameof(WaterfallDialog); this.configuration = configuration; }
public Services(TokensContext tokens, IOptions <OAuth2Keys> auth2Keys) { _tokens = tokens; _auth2Keys = auth2Keys.Value; }
public QBOController(IServices services, TokensContext tokens) { _services = services; _tokens = tokens; }
public Services(TokensContext tokens) { _tokens = tokens; }