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(); }
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); } }
public WishlistController(ShopifyContext context) { _context = context; }
public HomeController(ShopifyContext context, IConfiguration config) { _context = context; _config = config; }