Example #1
0
        public async Task <ActionResult> EditMarketItem(int marketItemId, bool isRelisting = false)
        {
            var response = await MarketplaceReader.GetMarketItem(marketItemId);

            if (response == null)
            {
                return(RedirectToAction("Index"));
            }

            var currentUser = new Guid(User.Identity.GetUserId());

            if (response.UserId != currentUser)
            {
                return(RedirectToAction("MarketItem", new { marketItemId = marketItemId }));
            }

            var marketItem = new EditMarketItemModel
            {
                Title            = response.Title,
                Id               = response.Id,
                Type             = response.Type,
                CategoryId       = response.CategoryId,
                Price            = response.AskingPrice,
                Description      = response.Description,
                CurrentMainImage = response.MainImage,
                CurrentAltImage1 = response.AlternateImages.Take(1).FirstOrDefault(),
                CurrentAltImage2 = response.AlternateImages.Skip(1).Take(1).FirstOrDefault(),
                CurrentAltImage3 = response.AlternateImages.Skip(2).Take(1).FirstOrDefault(),
                CurrentAltImage4 = response.AlternateImages.Skip(3).Take(1).FirstOrDefault(),
                CurrencyId       = response.CurrencyId,
                //   Feature = response.MarketItem.Feature,
                CityId                       = response.GetCityId(),
                CountryId                    = response.GetCountryId(),
                ReservePrice                 = response.ReservePrice,
                LocationRegion               = response.LocationRegion,
                AllowPickup                  = response.AllowPickup,
                PickupOnly                   = response.PickupOnly,
                ShippingBuyerArrange         = response.ShippingBuyerArrange,
                ShippingNational             = response.ShippingNational,
                ShippingInternational        = response.ShippingInternational,
                ShippingNationalPrice        = response.ShippingNationalPrice,
                ShippingNationalDetails      = response.ShippingNationalDetails,
                ShippingInternationalPrice   = response.ShippingInternationalPrice,
                ShippingInternationalDetails = response.ShippingInternationalDetails,
                IsRelisting                  = isRelisting,
                HasBids                      = response.Bids != null && response.Bids.Any(),
                Currencies                   = await CurrencyReader.GetCurrencies(),
                Categories                   = await MarketplaceReader.GetMarketCategories()
            };

            marketItem.SetCategories(response);

            return(View(marketItem));
        }
Example #2
0
        public async Task <ActionResult> MarketItem(int marketItemId)
        {
            var response = await MarketplaceReader.GetMarketItem(marketItemId);

            if (response == null)
            {
                return(RedirectToAction("Index"));
            }

            var currentUser = new Guid(User.Identity?.GetUserId() ?? Guid.Empty.ToString());

            response.AlternateImages.Add(response.MainImage);
            var marketItem = new MarketItemModel
            {
                IsUserListing                = (User.Identity.IsAuthenticated && response.UserId == currentUser),
                IsUserBuyer                  = response.BuyerUserId.HasValue && (User.Identity.IsAuthenticated && response.BuyerUserId.Value == currentUser),
                Title                        = response.Title,
                Id                           = response.Id,
                CategoryId                   = response.CategoryId,
                Symbol                       = response.Symbol,
                AskingPrice                  = response.AskingPrice,
                Description                  = response.Description,
                MainImage                    = response.MainImage,
                AlternateImages              = response.AlternateImages,
                CloseDate                    = response.CloseDate,
                Created                      = response.Created,
                CurrencyId                   = response.CurrencyId,
                Feature                      = response.Feature,
                Location                     = response.Location,
                Questions                    = response.Questions,
                ReservePrice                 = response.ReservePrice,
                CurrentBidPrice              = response.CurrentBidPrice,
                Bids                         = response.Bids,
                Status                       = response.Status,
                Type                         = response.Type,
                UserName                     = response.UserName,
                AllowPickup                  = response.AllowPickup,
                PickupOnly                   = response.PickupOnly,
                ShippingBuyerArrange         = response.ShippingBuyerArrange,
                ShippingNational             = response.ShippingNational,
                ShippingInternational        = response.ShippingInternational,
                ShippingNationalPrice        = response.ShippingNationalPrice,
                ShippingNationalDetails      = response.ShippingNationalDetails,
                ShippingInternationalPrice   = response.ShippingInternationalPrice,
                ShippingInternationalDetails = response.ShippingInternationalDetails,
                HasBuyersFeedback            = response.HasBuyersFeedback,
                HasSellersFeedback           = response.HasSellersFeedback,
                SellersTrustRating           = response.UserTrustRating,
                BuyerUserName                = response.BuyerUserName,
                BuyersTrustRating            = response.BuyerTrustRating,
                IsAuction                    = response.Type == MarketItemType.Auction,
                NoReserve                    = response.ReservePrice <= 0,
                ReserveMet                   = response.CurrentBidPrice >= response.ReservePrice,
            };

            var output = new MarketPlaceModel
            {
                CategoryId = marketItem.CategoryId,
                Categories = await MarketplaceReader.GetMarketCategories(),
                Locations  = StaticDataCache.Locations.Where(x => x.ParentId == 0).OrderBy(x => x.Name).ToList(),
                Currencies = await CurrencyReader.GetCurrencies(),
                SortBy     = Resources.Market.marketItemSortyByTitle,
                MarketItem = marketItem
            };

            return(View("MarketPlace", output));
        }