public async Task <List <Recipe> > GetListAsync(string recipeName) { List <Recipe> recipeList = new List <Recipe>(); string table = "recipes"; string collumn = "recipename"; return(await Task.Run(async() => { MySqlCommand msc = new SqlQuerySort().SortMSC(recipeName, table, collumn); try { DataSet ds = await new SQLConnect().DynamicSimpleListSQL(msc); foreach (DataRow r in ds.Tables[0].Rows) { Recipe recipe = new Recipe((int)r[0], (string)r[1], (string)r[3], await GetIngredients((int)r[0]), Convert.ToSingle(r[2])); recipeList.Add(recipe); } } catch (NullReferenceException e) { Console.WriteLine(e); } return recipeList; })); }
public async Task <List <Recipe> > GetRange(string recipeName, int limit, int offset) { List <Recipe> recipeList = new List <Recipe>(); string table = "recipes"; string collumn = "recipename"; return(await Task.Run(async() => { MySqlCommand msc = new SqlQuerySort().SortMSCInterval(recipeName, table, collumn, limit, offset); DataSet ds = await new SQLConnect().DynamicSimpleListSQL(msc); foreach (DataRow r in ds.Tables[0].Rows) { Recipe recipe = new Recipe((int)r[0], (string)r[1], (string)r[3], await GetIngredients((int)r[0]), Convert.ToSingle(r[2]));; recipeList.Add(recipe); } foreach (Recipe r in recipeList) { r.deleteDuplicates(); } return recipeList; })); }