public async Task SeedAsync()
        {
            _ctx.Database.EnsureCreated();
            StoreUser user = await _userManager.FindByEmailAsync("*****@*****.**");

            if (user == null)
            {
                user = new StoreUser()
                {
                    FirstName = "Roman",
                    LastName  = "Mayerson",
                    Email     = "*****@*****.**",
                    UserName  = "******"
                };

                var result = await _userManager.CreateAsync(user, "1q2w3e4R!");

                if (result != IdentityResult.Success)
                {
                    throw new InvalidOperationException("Could not create new user in seeder");
                }
            }

            if (!_ctx.Products.Any())
            {
                //Need to create sample data
                var filepath = Path.Combine(_hosting.ContentRootPath, "Data/products.json");
                var json     = File.ReadAllText(filepath);
                var products = JsonConvert.DeserializeObject <IEnumerable <Product> >(json);
                _ctx.Products.AddRange(products);

                _ctx.SaveChanges();
            }

            if (_ctx.Products.Any() && (!_ctx.Orders.Any()))
            {
                //Need to create sample data

                _ctx.Orders.Add(new Order
                {
                    User        = user,
                    OrderDate   = DateTime.Now,
                    OrderNumber = "ababab122",
                    Items       = new List <OrderItem>()
                    {
                        new OrderItem()
                        {
                            Product  = _ctx.Products.First(),
                            Quantity = 7,
                        }
                    }
                });;

                _ctx.SaveChanges();
            }

            //var order = _ctx.Orders.Where(o => o.Id == 1).FirstOrDefault();
            //if (order == null)
            //{
            //    order.Items = new List<OrderItem>()
            //        {
            //       new OrderItem()
            //       {
            //           Product=products.First(),
            //           Quantity=5,
            //           UnitPrice = products.First().Price

            //       }
            //        };
            //}
        }
 public bool SaveAll()
 {
     return(_context.SaveChanges() > 0);
 }