public IActionResult Products() { var userName = HttpContext.User.Identity.Name; User user = _userService.All().First(u => u.Login == userName); Shop shop = _shopService.All().First(s => s.Id == user.ShopId); ViewBag.Categories = _categoryService.All(); ViewBag.Shops = _shopService.All(); ViewBag.UserId = user.Id; var result = ProductService.GetProductsInStock(_db, _postgresContext); return(View(result)); }
public IActionResult BookingList() { var userName = HttpContext.User.Identity.Name; User user = _userService.All().First(u => u.Login == userName); Shop shop = _shopService.All().First(s => s.Id == user.ShopId); return(View(_bookingService.All() .Where(x => x.ShopId == shop.Id) .OrderByDescending(x => x.Id) .Select(x => new BookingListVM() { Date = x.Date, Id = x.Id, Debt = x.Debt, Pay = x.Pay, Sum = x.Sum, Status = x.Status, ProductTitle = _bookingProductService.All() .Include(z => z.Product).FirstOrDefault(z => z.BookingId == x.Id).Product.Title ?? "" }))); }