Пример #1
0
        private async Task LoginShop(string shopDomain, string token)
        {
            Models.Shop shop = null;
            using (var context = new ShopifyContext())
            {
                shop = await context.Shops.SingleOrDefaultAsync(s => s.Domain == shopDomain);

                if (shop == null)
                {
                    shop = new Models.Shop(shopDomain, token);
                    context.Shops.Add(shop);
                }
                else
                {
                    shop.Token = token;
                }

                await context.SaveChangesAsync();
            }

            var session = HttpContext.Session;
            await session.LoadAsync();

            session.SetInt32(Constants.ShopId, shop.Id);
            await session.CommitAsync();
        }
Пример #2
0
        private async Task <Models.Shop> GetShop()
        {
            var session = HttpContext.Session;
            await session.LoadAsync();

            var id = session.GetInt32(Constants.ShopId);

            if (id == null)
            {
                return(null);
            }

            using (var context = new ShopifyContext())
            {
                var shop = await context.Shops.FindAsync(id);

                return(shop);
            }
        }
Пример #3
0
 public WishlistController(ShopifyContext context)
 {
     _context = context;
 }
Пример #4
0
 public HomeController(ShopifyContext context, IConfiguration config)
 {
     _context = context;
     _config  = config;
 }