Skip to content

Instantly share code, notes, and snippets.

@pawelel
Last active October 16, 2021 11:58
Show Gist options
  • Save pawelel/e1c0083f97e4c33c1adbe94491fae1ea to your computer and use it in GitHub Desktop.
Save pawelel/e1c0083f97e4c33c1adbe94491fae1ea to your computer and use it in GitHub Desktop.
return static list
public class DataBase
{
public static List<Product> GetProducts()
{
List<Product> products = new List<Product>
{
new Product
{
Id=1,
Name= "Nice dress",
Price= 2.25m
},
new Product
{
Id=2,
Name="Laptop Tohiba",
Price=1759.00m
},
new Product
{
Id=3,
Name="",
},
new Product
{
Id=4,
Name="Multi dimmensional water",
Price= 5999.00m },
new Product
{
Id=5,
Name="Rope pills forte ultra max",
Price= 7.99m },
new Product
{
Id=6,
Name="Toilet paper in Australia",
Price= 1700.00m },
new Product
{
Id=7,
Name="Master degree on CIA",
Price= 3000.00m },
new Product
{
Id=8,
Name="Bread with chokolade",
Price= 5.95m },
new Product
{
Id=9,
Name="1 night at covid chamber",
Price= 6.99m },
new Product
{
Id=10,
Name="Some real thoughts",
Price= 999999.99m },
};
return products;
}
public static Product GetProduct(string slug)
{
List<Product> products = DataBase.GetProducts();
foreach (var product in products)
{
if (product.Slug == slug)
{
return product;
}
}
return null;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment