Beispiel #1
0
        public async Task <IActionResult> Index()
        {
            AdvertFilter filter = new AdvertFilter {
                CurrentPage = 1, Size = 6
            };
            var response = await _advertApiClient.GetAdvertsByFilterAsync(filter);

            ViewBag.Adverts = response.Data;

            var cats = await _categoryApiClient.GetCategoriesAsync();

            ViewBag.Categories  = cats.Data;
            ViewBag.Size        = 30;
            ViewBag.CurrentPage = 1;
            return(View());
        }
        public async Task <IActionResult> EditAdvert(long id)
        {
            var response = await _advertApiClient.GetAdvertsByFilterAsync(new AdvertFilter { AdvertId = id, Size = 1, CurrentPage = 1 });

            var ad = response.Data.FirstOrDefault();

            ViewBag.Advert = ad;
            var cats = await _categoryApiClient.GetCategoriesAsync();

            ViewBag.Categories = cats.Data;

            if (response.HasErrors)
            {
                return(View("Error", new ErrorViewModel {
                    RequestId = response.Errors.FirstOrDefault()
                }));
            }
            return(View());
        }