public async Task <IActionResult> AddInventory(string ShopId, string Name, string SKU, string Option, string Category) { ClaimsPrincipal principal = HttpContext.User as ClaimsPrincipal; var UserId = _userManager.GetUserId(principal); UsersShoperToken shop = _dbContext.ShoperToken.First <UsersShoperToken>(x => (x.UserID == UserId && x.Id == Int32.Parse(ShopId))); Inventories inventories = new Inventories() { ShopUrl = shop.ShopUrl, Sku = SKU, Category = Category, Name = Name, Option = Option, UserID = UserId, ShopId = ShopId, Status = "Otwarta" }; _dbContext.Inventories.Add(inventories); _dbContext.SaveChanges(); List <Inventories> _inventories = _dbContext.Inventories.Where <Inventories>(x => (x.UserID == UserId && x.ShopId == ShopId)).ToList <Inventories>(); ShopCategories shopCategories = await ShopCategories.GetCategories(shop.ShopUrl, shop.Token); Tuple <ShopCategories, string, List <Inventories> > tuple = new Tuple <ShopCategories, string, List <Inventories> >(shopCategories, ShopId, _inventories); return(View("Inventories", tuple)); }
public async Task <IActionResult> Inventory(string ShopId) { ClaimsPrincipal principal = HttpContext.User as ClaimsPrincipal; var UserId = _userManager.GetUserId(principal); UsersShoperToken shop = _dbContext.ShoperToken.First <UsersShoperToken>(x => (x.UserID == UserId && x.Id == Int32.Parse(ShopId))); List <Inventories> inventories = _dbContext.Inventories.Where <Inventories>(x => (x.UserID == UserId && x.ShopId == ShopId)).ToList <Inventories>(); ShopCategories shopCategories = await ShopCategories.GetCategories(shop.ShopUrl, shop.Token); Tuple <ShopCategories, string, List <Inventories> > tuple = new Tuple <ShopCategories, string, List <Inventories> >(shopCategories, ShopId, inventories); return(View("Inventories", tuple)); }