private void export_Clicked(object sender, EventArgs e) { string sql = ""; List <Recipe> recipies = RecipeRepository.FindAll().Result; if (recipies.Count > 0) { sql += "INSERT INTO Recipe (Id,Name,Note,CreatedAt,UpdatedAt,Favourite) VALUES \n"; foreach (var item in recipies) { Console.WriteLine(item.CreatedAt); sql += "(" + item.Id + ",'" + item.Name + "','" + item.Note + "'," + item.CreatedAt.ToBinary() + "," + item.UpdatedAt.ToBinary() + "," + item.Favourite + "),\n"; } sql = sql.Remove(sql.Length - 2); sql += ";?\n"; } sql += "-- ------------------------------\n"; List <Product> products = ProductRepository.FindAll().Result; if (products.Count > 0) { sql += "INSERT INTO Product (Id,Name,Quantity,CreatedAt,UpdatedAt,RecipeId) VALUES \n"; foreach (var item in products) { sql += "(" + item.Id + ",'" + item.Name + "','" + item.Quantity.ToString().Replace(',', '.') + "'," + item.CreatedAt.ToBinary() + "," + item.UpdatedAt.ToBinary() + "," + item.RecipeId + "),\n"; } sql = sql.Remove(sql.Length - 2); sql += ";?\n"; } sql += "-- ------------------------------\n"; List <Ingredient> ingredients = IngredientRepository.FindAll().Result; if (ingredients.Count > 0) { sql += "INSERT INTO Ingredient (Id,Name,Quantity,RecipeId) VALUES \n"; foreach (var item in ingredients) { sql += "(" + item.Id + ",'" + item.Name + "'," + item.Quantity.ToString().Replace(',', '.') + "," + item.RecipeId + "),\n"; } sql = sql.Remove(sql.Length - 2); sql += ";?\n\n"; } var filename = "minticeapp_" + DateTime.Now.ToString("yyyy-MM-dd_HH-mm-ss") + ".sql"; var fileCopyName = Path.Combine("/storage/emulated/0/MintIceApp/Export", filename); System.IO.File.WriteAllText(fileCopyName, sql); CrossToastPopUp.Current.ShowToastMessage("Baza danych została wyeksportowana (Pamięć wewnętrzna/MintIceApp/Export/" + filename); }