Esempio n. 1
0
        public static void SetAuction(AuctionHouseElement auction)
        {
            var type       = (TypeAuction)Enum.Parse(typeof(TypeAuction), auction.Type);
            var auctionDAL = new Auction.DataAccess.Models.Auction()
            {
                Name     = auction.Name,
                Location = auction.Location,
                Type     = (DataAccess.Models.TypeAuction)type
            };

            IUnityContainer container       = UnityConfig.GetConfiguredContainer();
            var             auctionProvider = container.Resolve <DataAccess.Repositories.IAuctionProvider>();

            auctionProvider.Create(auctionDAL);
        }
        public ActionResult Categories()
        {
            object auctionName;
            AuctionHouseElement        auction  = null;
            List <AuctionHouseElement> auctions = new List <AuctionHouseElement>();

            if (Url.RequestContext.RouteData.Values.TryGetValue("auction", out auctionName))
            {
                auction = config.AuctionHouses.Search((string)auctionName);
                if (auction != null)
                {
                    Infrastructure.Auctions.SetAuction(auction);
                }
            }

            if (auction == null)
            {
                foreach (AuctionHouseElement auctionEl in config.AuctionHouses)
                {
                    auctions.Add(new AuctionHouseElement()
                    {
                        Name = auctionEl.Name, Location = auctionEl.Location, Type = auctionEl.Type
                    });
                }

                Infrastructure.Auctions.SetAuction(auctions.First());
            }

            IEnumerable <CategoryViewModel> categoriesVM = null;

            try
            {
                var categories = Task.Run(async() =>
                {
                    return(await _categoryService.ShowAwalaibleCategoriesAsync());
                }).Result;

                categoriesVM = categories.Select(cat => Mapper.Map <CategoryViewModel>(cat));
            }
            catch (AggregateException)
            {
                ////log
            }

            return(PartialView("~/Views/Shared/_Category.cshtml", categoriesVM));
        }