private List <Product_DB> CreateProducts(int count) { var products = new List <Product_DB>(); for (int i = 1; i <= count; i++) { products.Add(Product_DB.GetDefaultValue(i)); } return(products); }
private IEnumerable <Order_DB> CreateOrders(int count) { var orders = new List <Order_DB>(); for (int i = 1; i <= count; i++) { var order = Order_DB.GetDefaultValue(i); order.Status = new OrderStatus_DB { Id = order.Status_Id, Name = OrderStatus.Created.ToString() }; order.User = User_DB.GetDefaultValue(order.User_Id); order.Order_Composition .ForEach(oc => oc.Product = Product_DB.GetDefaultValue(oc.Product_Id)); orders.Add(order); } return(orders); }
public List <object> GetDefaultValue() { var seed = new List <object>(); var categories = new List <Category_DB>(); for (int i = 1; i < 5; i++) { var cat = Category_DB.GetDefaultValue(i); categories.Add(cat); } var products = new List <Product_DB>(); for (int i = 1; i <= categories.Count * 20; i++) { var prod = Product_DB.GetDefaultValue(i); products.Add(prod); } var productCategory = new List <ProductCategory_DB>(); for (int i = 0; i < categories.Count; i++) { var from = i * 20; var to = (i + 1) * 20; for (int j = from; j < to; j++) { var prodCat = new ProductCategory_DB { Category_Id = categories[i].Id, Product_Id = products[j].Id }; productCategory.Add(prodCat); } } var statuses = new List <OrderStatus_DB> { new OrderStatus_DB { Id = 1, Name = Entities.OrderStatus.Created.ToString() }, new OrderStatus_DB { Id = 2, Name = Entities.OrderStatus.InProgress.ToString() }, new OrderStatus_DB { Id = 3, Name = Entities.OrderStatus.Completed.ToString() } }; var users = new List <User_DB>(); for (int i = 1; i < 5; i++) { var user = User_DB.GetDefaultValue(i); user.Role_Id = 1; users.Add(user); } var roles = new List <Role_DB> { new Role_DB { Id = 1, Name = UserRoles.Admin.ToString() }, new Role_DB { Id = 2, Name = UserRoles.User.ToString() } }; seed.AddRange(categories); seed.AddRange(products); seed.AddRange(productCategory); seed.AddRange(statuses); seed.AddRange(users); seed.AddRange(roles); return(seed); }