コード例 #1
0
 public ActionResult Edit(AuctionModel model)
 {
     return View();
 }
コード例 #2
0
 public ActionResult Delete(AuctionModel model)
 {
     return View();
 }
コード例 #3
0
        public ActionResult Create()
        {
            //if (!_permissionService.Authorize(StandardPermissionProvider.ManageProducts))
            //    return AccessDeniedView();

            var model = new AuctionModel();
            PrepareAuctionModel(model, null, true, true);
            //AddLocales(_languageService, model.Locales);
            //PrepareAclModel(model, null, false);
            //PrepareStoresMappingModel(model, null, false);
            return View(model);
        }
コード例 #4
0
 public ActionResult Create(AuctionModel model)
 {
     return View();
 }
コード例 #5
0
        public ActionResult AuctionProductUpdate(AuctionModel.AuctionProductModel model)
        {
            //if (!_permissionService.Authorize(StandardPermissionProvider.ManageProducts))
            //    return AccessDeniedView();

            var relatedProduct = _productService.GetRelatedProductById(model.Id);
            if (relatedProduct == null)
                throw new ArgumentException("No related product found with the specified id");

            //a vendor should have access only to his products
            if (_workContext.CurrentVendor != null)
            {
                var product = _productService.GetProductById(relatedProduct.ProductId1);
                if (product != null && product.VendorId != _workContext.CurrentVendor.Id)
                {
                    return Content("This is not your product");
                }
            }

            relatedProduct.DisplayOrder = model.DisplayOrder;
            _productService.UpdateRelatedProduct(relatedProduct);

            return new NullJsonResult();
        }
コード例 #6
0
        public ActionResult RelatedProductAddPopup(string btnId, string formId, AuctionModel.AddRelatedProductModel model)
        {
            //if (!_permissionService.Authorize(StandardPermissionProvider.ManageProducts))
            //    return AccessDeniedView();

            if (model.SelectedProductIds.Count() > 1)
            {
                ModelState.AddModelError("NumberOfProducts", "Please select a single product.");
                model.IsLoggedInAsVendor = _workContext.CurrentVendor != null;
                ViewBag.RefreshPage = false;
                ViewBag.btnId = btnId;
                ViewBag.formId = formId;
                return View(model);
            }

            if (model.SelectedProductIds != null)
            {
                foreach (int id in model.SelectedProductIds)
                {
                    var product = _productService.GetProductById(id);
                    if (product != null)
                    {
                        //a vendor should have access only to his products
                        //if (_workContext.CurrentVendor != null && product.VendorId != _workContext.CurrentVendor.Id)
                        //    continue;

                        var existingAuctionedProduct = _auctionService.GetAuctionedProductByAuctionId(model.AuctionId);
                        if (existingAuctionedProduct == null)
                        {
                            _auctionService.InsertAuctionedProduct(model.AuctionId, product.Id);
                        }
                    }
                }
            }

            //a vendor should have access only to his products
            model.IsLoggedInAsVendor = _workContext.CurrentVendor != null;
            ViewBag.RefreshPage = true;
            ViewBag.btnId = btnId;
            ViewBag.formId = formId;
            return View(model);
        }
コード例 #7
0
        public ActionResult RelatedProductAddPopupList(DataSourceRequest command, AuctionModel.AddRelatedProductModel model)
        {
            //if (!_permissionService.Authorize(StandardPermissionProvider.ManageProducts))
            //    return AccessDeniedView();

            //a vendor should have access only to his products
            if (_workContext.CurrentVendor != null)
            {
                model.SearchVendorId = _workContext.CurrentVendor.Id;
            }

            var products = _productService.SearchProducts(
                categoryIds: new List<int> { model.SearchCategoryId },
                manufacturerId: model.SearchManufacturerId,
                storeId: model.SearchStoreId,
                vendorId: model.SearchVendorId,
                //productType: model.SearchProductTypeId > 0 ? (ProductType?)model.SearchProductTypeId : null,
                keywords: model.SearchProductName,
                pageIndex: command.Page - 1,
                pageSize: command.PageSize,
                showHidden: true
                );
            var gridModel = new DataSourceResult();
            //gridModel.Data = products.Select(x => x.ToModel());
            gridModel.Data = products.Select(x => new ModelsMapper().CreateMap<Product, ProductModel>(x));
            gridModel.Total = products.TotalCount;

            return Json(gridModel);
        }
コード例 #8
0
        protected virtual void PrepareAuctionModel(AuctionModel model, Auction auction,
            bool setPredefinedValues, bool excludeProperties)
        {
            if (model == null)
                throw new ArgumentNullException("model");

            //if (auction != null)
            //{
            //    var parentGroupedProduct = _productService.GetProductById(auction.ParentGroupedProductId);
            //    if (parentGroupedProduct != null)
            //    {
            //        model.AssociatedToProductId = auction.ParentGroupedProductId;
            //        model.AssociatedToProductName = parentGroupedProduct.Name;
            //    }
            //}

            model.PrimaryStoreCurrencyCode = _currencyService.GetCurrencyById(_currencySettings.PrimaryStoreCurrencyId).CurrencyCode;
            //model.BaseWeightIn = _measureService.GetMeasureWeightById(_measureSettings.BaseWeightId).Name;
            //model.BaseDimensionIn = _measureService.GetMeasureDimensionById(_measureSettings.BaseDimensionId).Name;
            if (auction != null)
            {
                model.CreatedOn = _dateTimeHelper.ConvertToUserTime(auction.CreatedOnUtc, DateTimeKind.Utc);
                model.UpdatedOn = _dateTimeHelper.ConvertToUserTime(auction.UpdatedOnUtc, DateTimeKind.Utc);
            }

            ////little performance hack here
            ////there's no need to load attributes, categories, manufacturers when creating a new product
            ////anyway they're not used (you need to save a product before you map add them)
            //if (auction != null)
            //{
            //    foreach (var productAttribute in _productAttributeService.GetAllProductAttributes())
            //    {
            //        model.AvailableProductAttributes.Add(new SelectListItem
            //        {
            //            Text = productAttribute.Name,
            //            Value = productAttribute.Id.ToString()
            //        });
            //    }
            //    foreach (var manufacturer in _manufacturerService.GetAllManufacturers(showHidden: true))
            //    {
            //        model.AvailableManufacturers.Add(new SelectListItem
            //        {
            //            Text = manufacturer.Name,
            //            Value = manufacturer.Id.ToString()
            //        });
            //    }
            //    var allCategories = _categoryService.GetAllCategories(showHidden: true);
            //    foreach (var category in allCategories)
            //    {
            //        model.AvailableCategories.Add(new SelectListItem
            //        {
            //            Text = category.GetFormattedBreadCrumb(allCategories),
            //            Value = category.Id.ToString()
            //        });
            //    }
            //}

            ////copy product
            //if (auction != null)
            //{
            //    model.CopyProductModel.Id = auction.Id;
            //    model.CopyProductModel.Name = "Copy of " + auction.Name;
            //    model.CopyProductModel.Published = true;
            //    model.CopyProductModel.CopyImages = true;
            //}

            ////templates
            //var templates = _productTemplateService.GetAllProductTemplates();
            //foreach (var template in templates)
            //{
            //    model.AvailableProductTemplates.Add(new SelectListItem
            //    {
            //        Text = template.Name,
            //        Value = template.Id.ToString()
            //    });
            //}

            //vendors
            //model.IsLoggedInAsVendor = _workContext.CurrentVendor != null;
            model.AvailableVendors.Add(new SelectListItem
            {
                Text = _localizationService.GetResource("Admin.Catalog.Products.Fields.Vendor.None"),
                Value = "0"
            });
            var vendors = _vendorService.GetAllVendors(showHidden: true);
            foreach (var vendor in vendors)
            {
                model.AvailableVendors.Add(new SelectListItem
                {
                    Text = vendor.Name,
                    Value = vendor.Id.ToString()
                });
            }

            ////delivery dates
            //model.AvailableDeliveryDates.Add(new SelectListItem
            //{
            //    Text = _localizationService.GetResource("Admin.Catalog.Products.Fields.DeliveryDate.None"),
            //    Value = "0"
            //});
            //var deliveryDates = _shippingService.GetAllDeliveryDates();
            //foreach (var deliveryDate in deliveryDates)
            //{
            //    model.AvailableDeliveryDates.Add(new SelectListItem
            //    {
            //        Text = deliveryDate.Name,
            //        Value = deliveryDate.Id.ToString()
            //    });
            //}

            ////warehouses
            //var warehouses = _shippingService.GetAllWarehouses();
            //model.AvailableWarehouses.Add(new SelectListItem
            //{
            //    Text = _localizationService.GetResource("Admin.Catalog.Products.Fields.Warehouse.None"),
            //    Value = "0"
            //});
            //foreach (var warehouse in warehouses)
            //{
            //    model.AvailableWarehouses.Add(new SelectListItem
            //    {
            //        Text = warehouse.Name,
            //        Value = warehouse.Id.ToString()
            //    });
            //}

            ////multiple warehouses
            //foreach (var warehouse in warehouses)
            //{
            //    var pwiModel = new ProductModel.ProductWarehouseInventoryModel
            //    {
            //        WarehouseId = warehouse.Id,
            //        WarehouseName = warehouse.Name
            //    };
            //    if (auction != null)
            //    {
            //        var pwi = auction.ProductWarehouseInventory.FirstOrDefault(x => x.WarehouseId == warehouse.Id);
            //        if (pwi != null)
            //        {
            //            pwiModel.WarehouseUsed = true;
            //            pwiModel.StockQuantity = pwi.StockQuantity;
            //            pwiModel.ReservedQuantity = pwi.ReservedQuantity;
            //            pwiModel.PlannedQuantity = _shipmentService.GetQuantityInShipments(auction, pwi.WarehouseId, true, true);
            //        }
            //    }
            //    model.ProductWarehouseInventoryModels.Add(pwiModel);
            //}

            ////product tags
            //if (auction != null)
            //{
            //    var result = new StringBuilder();
            //    for (int i = 0; i < auction.ProductTags.Count; i++)
            //    {
            //        var pt = auction.ProductTags.ToList()[i];
            //        result.Append(pt.Name);
            //        if (i != auction.ProductTags.Count - 1)
            //            result.Append(", ");
            //    }
            //    model.ProductTags = result.ToString();
            //}

            ////tax categories
            //var taxCategories = _taxCategoryService.GetAllTaxCategories();
            //model.AvailableTaxCategories.Add(new SelectListItem { Text = "---", Value = "0" });
            //foreach (var tc in taxCategories)
            //    model.AvailableTaxCategories.Add(new SelectListItem { Text = tc.Name, Value = tc.Id.ToString(), Selected = auction != null && !setPredefinedValues && tc.Id == auction.TaxCategoryId });

            ////baseprice units
            //var measureWeights = _measureService.GetAllMeasureWeights();
            //foreach (var mw in measureWeights)
            //    model.AvailableBasepriceUnits.Add(new SelectListItem { Text = mw.Name, Value = mw.Id.ToString(), Selected = auction != null && !setPredefinedValues && mw.Id == auction.BasepriceUnitId });
            //foreach (var mw in measureWeights)
            //    model.AvailableBasepriceBaseUnits.Add(new SelectListItem { Text = mw.Name, Value = mw.Id.ToString(), Selected = auction != null && !setPredefinedValues && mw.Id == auction.BasepriceBaseUnitId });

            ////specification attributes
            //var specificationAttributes = _specificationAttributeService.GetSpecificationAttributes();
            //for (int i = 0; i < specificationAttributes.Count; i++)
            //{
            //    var sa = specificationAttributes[i];
            //    model.AddSpecificationAttributeModel.AvailableAttributes.Add(new SelectListItem { Text = sa.Name, Value = sa.Id.ToString() });
            //    if (i == 0)
            //    {
            //        //attribute options
            //        foreach (var sao in _specificationAttributeService.GetSpecificationAttributeOptionsBySpecificationAttribute(sa.Id))
            //            model.AddSpecificationAttributeModel.AvailableOptions.Add(new SelectListItem { Text = sao.Name, Value = sao.Id.ToString() });
            //    }
            //}
            ////default specs values
            //model.AddSpecificationAttributeModel.ShowOnProductPage = true;

            ////discounts
            //model.AvailableDiscounts = _discountService
            //    .GetAllDiscounts(DiscountType.AssignedToSkus, showHidden: true)
            //    .Select(d => d.ToModel())
            //    .ToList();
            //if (!excludeProperties && auction != null)
            //{
            //    model.SelectedDiscountIds = auction.AppliedDiscounts.Select(d => d.Id).ToArray();
            //}

            ////default values
            //if (setPredefinedValues)
            //{
            //    model.MaximumCustomerEnteredPrice = 1000;
            //    model.MaxNumberOfDownloads = 10;
            //    model.RecurringCycleLength = 100;
            //    model.RecurringTotalCycles = 10;
            //    model.RentalPriceLength = 1;
            //    model.StockQuantity = 10000;
            //    model.NotifyAdminForQuantityBelow = 1;
            //    model.OrderMinimumQuantity = 1;
            //    model.OrderMaximumQuantity = 10000;

            //    model.UnlimitedDownloads = true;
            //    model.IsShipEnabled = true;
            //    model.AllowCustomerReviews = true;
            //    model.Published = true;
            //    model.VisibleIndividually = true;
            //}
        }
コード例 #9
0
        public ActionResult Edit(AuctionModel model)
        {
            if (model == null)
                throw new ArgumentNullException("model");

            if (ModelState.IsValid)
            {
                var auction = new ModelsMapper().CreateMap<AuctionModel, Auction>(model);
                auction.UpdatedOnUtc = DateTime.UtcNow;
                auction.StartingDate = DateTime.UtcNow;
                _auctionService.UpdateAuction(auction);
                return RedirectToAction("Index");
            }

            PrepareAuctionModel(model, null, true, true);
            return View();
        }