public static Product CreateProduct(this RetailDbContext db) { var id = IdFactory.Next(); var product = new Product { ProductName = $"Product {id}", Active = true, Price = id * 2 + 0.99m, SalesPrice = id + 0.99m, }; db.Add(product); return(product); }
public static Store CreateStore(this RetailDbContext db) { var id = IdFactory.Next(); var store = new Store { Address = $"{id} Main Street", City = $"{id}ville", Province = $"{id} District", Country = $"{id}land", PostalCode = $"{id}", PhoneNumber = $"({id}) {id}-{id}", StoreName = $"Store {id}", Active = true, }; db.Add(store); return(store); }
public void SimpleDbTest() { //Add a product var product = new Product() { ProductName = $"Product {Guid.NewGuid()}" }; _dbRetail.Add(product); _dbRetail.SaveChanges(); //Purge all products var products = _dbRetail.Products.ToList(); foreach (var p in products) { _dbRetail.Remove(p); } _dbRetail.SaveChanges(); }
public static Customer CreateCustomer(this RetailDbContext db) { var id = IdFactory.Next(); var customer = new Customer { FirstName = $"Bob{id}", LastName = $"Robertson{id}", Address = $"{id} Main Street", City = $"{id}ville", Province = $"{id} District", Country = $"{id}land", PostalCode = $"{id}", PhoneNumber = $"({id}) {id}-{id}", Active = true, Discount = 0.0 }; db.Add(customer); return(customer); }