Ejemplo n.º 1
0
 /// <summary>
 /// Saves a recipe to the database asyncronously
 /// </summary>
 /// <param name="recipe">The recipe to store</param>
 /// <returns>An integer indicating the key of the recipe or the affected rows (if updating)</returns>
 public async Task <int> SaveRecipeAsync(Recipe recipe)
 {
     if (RecipeList != null && RecipeList.Any(r => r.Id == recipe.Id || r.Name == recipe.Name))
     {
         return(await _database.UpdateAsync(recipe));
     }
     else if (recipe.Id != 0)
     {
         return(await _database.InsertOrReplaceAsync(recipe));
     }
     else
     {
         return(await _database.InsertAsync(recipe));
     }
 }