//public async Task<IActionResult> Index(Guid categoryId)
        //{
        //    var currentBasketId = Request.Cookies.GetCurrentBasketId(settings);

        //    var getBasket = currentBasketId == Guid.Empty ? Task.FromResult<Basket>(null) :
        //        shoppingBasketService.GetBasket(currentBasketId);

        //    var getCategories = eventCatalogService.GetCategories();

        //    var getEvents = categoryId == Guid.Empty ? eventCatalogService.GetAll() :
        //        eventCatalogService.GetByCategoryId(categoryId);

        //    await Task.WhenAll(new Task[] { getBasket, getCategories, getEvents });

        //    var numberOfItems = getBasket.Result?.NumberOfItems ?? 0;

        //    return View(
        //        new EventListModel
        //        {
        //            Events = getEvents.Result,
        //            Categories = getCategories.Result,
        //            NumberOfItems = numberOfItems,
        //            SelectedCategory = categoryId
        //        }
        //    );
        //}

        public async Task <IActionResult> Index(Guid categoryId)
        {
            var currentBasketId = Request.Cookies.GetCurrentBasketId(settings);
            var result          = await eventCatalogService.GetCatalogBrowse(currentBasketId, categoryId);

            return(View(
                       new EventListModel
            {
                Events = result.Events,
                Categories = result.Categories,
                NumberOfItems = result.NumberOfItems,
                SelectedCategory = categoryId
            }
                       ));
        }
        //public async Task<IActionResult> Index(Guid categoryId)
        //{
        //    var currentBasketId = Request.Cookies.GetCurrentBasketId(settings);

        //    var getBasket = currentBasketId == Guid.Empty ? Task.FromResult<Basket>(null) :
        //        shoppingBasketService.GetBasket(currentBasketId);

        //    var getCategories = eventCatalogService.GetCategories();

        //    var getEvents = categoryId == Guid.Empty ? eventCatalogService.GetAll() :
        //        eventCatalogService.GetByCategoryId(categoryId);

        //    await Task.WhenAll(new Task[] { getBasket, getCategories, getEvents });

        //    var numberOfItems = getBasket.Result?.NumberOfItems ?? 0;

        //    return View(
        //        new EventListModel
        //        {
        //            Events = getEvents.Result,
        //            Categories = getCategories.Result,
        //            NumberOfItems = numberOfItems,
        //            SelectedCategory = categoryId
        //        }
        //    );
        //}

        public async Task <IActionResult> Index(Guid categoryId)
        {
            try
            {
                var currentBasketId = Request.Cookies.GetCurrentBasketId(settings);
                var result          = await eventCatalogService.GetCatalogBrowse(currentBasketId, categoryId, this._GetCurrentConext.HttpContext.Session.GetString("token"));

                return(View(
                           new EventListModel
                {
                    Events = result.Events,
                    Categories = result.Categories,
                    NumberOfItems = result.NumberOfItems,
                    SelectedCategory = categoryId
                }
                           ));
            }
            catch (Exception e)
            {
                return(RedirectToAction("Unathorized", "Account", new { msg = e.Message.ToString() }));
            }
        }