protected void gvTierPrices_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "UpdateTierPrice") { int index = Convert.ToInt32(e.CommandArgument); GridViewRow row = gvTierPrices.Rows[index]; HiddenField hfTierPriceID = row.FindControl("hfTierPriceID") as HiddenField; NumericTextBox txtQuantity = row.FindControl("txtQuantity") as NumericTextBox; DecimalTextBox txtPrice = row.FindControl("txtPrice") as DecimalTextBox; int tierPriceID = int.Parse(hfTierPriceID.Value); decimal price = txtPrice.Value; int quantity = txtQuantity.Value; TierPrice tierPrice = ProductManager.GetTierPriceByID(tierPriceID); if (tierPrice != null) { ProductManager.UpdateTierPrice(tierPrice.TierPriceID, tierPrice.ProductVariantID, quantity, price); } BindData(); } }
public void Can_save_and_load_tierPriceWithCustomerRole() { var tierPrice = new TierPrice { Quantity = 1, Price = 2, ProductVariant = GetTestProductVariant(), CustomerRole = new CustomerRole() { Name = "Administrators", FreeShipping = true, TaxExempt = true, Active = true, IsSystemRole = true, SystemName = "Administrators" } }; var fromDb = SaveAndLoadEntity(tierPrice); fromDb.ShouldNotBeNull(); fromDb.CustomerRole.ShouldNotBeNull(); fromDb.CustomerRole.Name.ShouldEqual("Administrators"); }
protected void gvTierPrices_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "UpdateTierPrice") { int index = Convert.ToInt32(e.CommandArgument); GridViewRow row = gvTierPrices.Rows[index]; HiddenField hfTierPriceId = row.FindControl("hfTierPriceId") as HiddenField; NumericTextBox txtQuantity = row.FindControl("txtQuantity") as NumericTextBox; DecimalTextBox txtPrice = row.FindControl("txtPrice") as DecimalTextBox; int tierPriceId = int.Parse(hfTierPriceId.Value); decimal price = txtPrice.Value; int quantity = txtQuantity.Value; TierPrice tierPrice = this.ProductService.GetTierPriceById(tierPriceId); if (tierPrice != null) { tierPrice.Quantity = quantity; tierPrice.Price = price; this.ProductService.UpdateTierPrice(tierPrice); } BindData(); } }
/// <summary> /// Prepare tier price model /// </summary> /// <param name="model">Tier price model</param> /// <param name="product">Product</param> /// <param name="tierPrice">Tier price</param> /// <param name="excludeProperties">Whether to exclude populating of some properties of model</param> /// <returns>Tier price model</returns> public virtual TierPriceModel PrepareTierPriceModel(TierPriceModel model, Category category, TierPrice tierPrice, bool excludeProperties = false) { if (category == null) { throw new ArgumentNullException(nameof(category)); } if (tierPrice != null) { //fill in model values from the entity if (model == null) { model = tierPrice.ToModel <TierPriceModel>(); } } //prepare available stores _baseAdminModelFactory.PrepareStores(model.AvailableStores); //prepare available customer roles _baseAdminModelFactory.PrepareCustomerRoles(model.AvailableCustomerRoles); return(model); }
protected void btnNewTierPrice_Click(object sender, EventArgs e) { try { ProductVariant productVariant = this.ProductService.GetProductVariantById(this.ProductVariantId); if (productVariant != null) { decimal price = txtNewPrice.Value; int quantity = txtNewQuantity.Value; var tierPrice = new TierPrice() { ProductVariantId = productVariant.ProductVariantId, Quantity = quantity, Price = price }; this.ProductService.InsertTierPrice(tierPrice); BindData(); } } catch (Exception exc) { processAjaxError(exc); } }
public override TierPriceModel PrepareTierPriceModel(TierPriceModel model, Product product, TierPrice tierPrice, bool excludeProperties = false) { if (product == null) { throw new ArgumentNullException(nameof(product)); } if (tierPrice != null) { //fill in model values from the entity if (model == null) { model = tierPrice.ToModel <TierPriceModel>(); } } //prepare available stores _baseAdminModelFactory.PrepareStores(model.AvailableStores); //prepare available customer roles IEnumerable <CustomerRole> availableCustomerRoles = _customerService.GetAllCustomerRoles() .Where(x => x.SystemName.Contains(B2BRole.RoleSuffix)); foreach (var customerRole in availableCustomerRoles) { model.AvailableCustomerRoles.Add(new SelectListItem { Value = customerRole.Id.ToString(), Text = customerRole.Name }); } return(model); }
public static TierPrice ToWebModel(this QuoteModule.Client.Model.TierPrice serviceModel, Currency currency) { var webModel = new TierPrice(currency); webModel.InjectFrom <NullableAndEnumValueInjecter>(serviceModel); webModel.Price = new Money(serviceModel.Price ?? 0, currency); return(webModel); }
public static QuoteModule.Client.Model.TierPrice ToQuoteServiceModel(this TierPrice webModel) { var serviceModel = new QuoteModule.Client.Model.TierPrice(); serviceModel.InjectFrom <NullableAndEnumValueInjecter>(webModel); serviceModel.Price = (double)webModel.Price.Amount; return(serviceModel); }
public virtual TierPrice ToLiquidTierPrice(Storefront.Model.TierPrice tierPrice) { var result = new TierPrice(); result.Price = tierPrice.Price.Amount * 100; result.Quantity = tierPrice.Quantity; return(result); }
public static ProductModel.TierPriceModel ToModel(this TierPrice entity, IDateTimeHelper dateTimeHelper) { var tierprice = entity.MapTo <TierPrice, ProductModel.TierPriceModel>(); tierprice.StartDateTime = entity.StartDateTimeUtc.ConvertToUserTime(dateTimeHelper); tierprice.EndDateTime = entity.EndDateTimeUtc.ConvertToUserTime(dateTimeHelper); return(tierprice); }
public static TierPrice ToEntity(this ProductModel.TierPriceModel model, TierPrice destination, IDateTimeHelper dateTimeHelper) { var tierprice = model.MapTo(destination); tierprice.StartDateTimeUtc = model.StartDateTime.ConvertToUtcTime(dateTimeHelper); tierprice.EndDateTimeUtc = model.EndDateTime.ConvertToUtcTime(dateTimeHelper); return(tierprice); }
public virtual quoteDto.TierPrice ToQuoteTierPriceDto(TierPrice webModel) { var serviceModel = new quoteDto.TierPrice(); serviceModel.InjectFrom <NullableAndEnumValueInjecter>(webModel); serviceModel.Price = (double)webModel.Price.Amount; return(serviceModel); }
public virtual TierPrice ToTierPrice(quoteDto.TierPrice tierPriceDto, Currency currency) { var result = new TierPrice(currency); result.InjectFrom <NullableAndEnumValueInjecter>(tierPriceDto); result.Price = new Money(tierPriceDto.Price ?? 0, currency); return(result); }
public static TierPrice ToShopifyModel(this Storefront.Model.TierPrice storefrontModel) { var shopifyModel = new TierPrice(); shopifyModel.Price = storefrontModel.ListPrice.Amount * 100; shopifyModel.Quantity = storefrontModel.Quantity; return(shopifyModel); }
public void ByProduct_Should_Throw_ArgumentException_If_ProductId_Is_Empty() { IQueryable <TierPrice> tierPrices = new TierPrice[0].AsQueryable(); Guid productId = Guid.Empty; var ex = Assert.Throws <ArgumentException>(() => TierPriceExtensions.ByProduct(tierPrices, productId)); Assert.Equal(nameof(productId), ex.ParamName); }
public virtual void UpdateTierPrice(TierPrice tierPrice) { Guard.NotNull(tierPrice, nameof(tierPrice)); _tierPriceRepository.Update(tierPrice); //event notification _services.EventPublisher.EntityUpdated(tierPrice); }
public static TierPrice ToWebModel(this VirtoCommerceQuoteModuleWebModelTierPrice serviceModel, Currency currency) { var webModel = new TierPrice(); webModel.InjectFrom <NullableAndEnumValueInjecter>(serviceModel); webModel.ListPrice = new Money(serviceModel.Price ?? 0, currency); return(webModel); }
public virtual TierPrice ToTierPrice(quoteDto.TierPrice tierPriceDto, Currency currency) { var result = new TierPrice(currency) { Quantity = tierPriceDto.Quantity ?? 1, Price = new Money(tierPriceDto.Price ?? 0, currency) }; return(result); }
public static TierPrice ToWebModel(this VirtoCommerceQuoteModuleWebModelTierPrice serviceModel, Currency currency) { var webModel = new TierPrice(currency); webModel.InjectFrom<NullableAndEnumValueInjecter>(serviceModel); webModel.Price = new Money(serviceModel.Price ?? 0, currency); return webModel; }
public static VirtoCommerceQuoteModuleWebModelTierPrice ToQuoteServiceModel(this TierPrice webModel) { var serviceModel = new VirtoCommerceQuoteModuleWebModelTierPrice(); serviceModel.InjectFrom <NullableAndEnumValueInjecter>(webModel); serviceModel.Price = (double)webModel.Price.Amount; return(serviceModel); }
public virtual quoteDto.TierPrice ToQuoteTierPriceDto(TierPrice webModel) { var result = new quoteDto.TierPrice { Quantity = webModel.Quantity, Price = (double)webModel.Price.Amount }; return(result); }
/// <summary> /// Inserts a tier price /// </summary> /// <param name="tierPrice">Tier price</param> public virtual void InsertTierPrice(TierPrice tierPrice) { if (tierPrice == null) { throw new ArgumentNullException(nameof(tierPrice)); } _tierPriceRepository.Insert(tierPrice); //event notification _eventPublisher.EntityInserted(tierPrice); }
public TierPriceEntity FromModel(TierPrice item) { if (item == null) { throw new ArgumentNullException(nameof(item)); } Price = item.Price; Quantity = item.Quantity; return(this); }
public virtual void DeleteTierPrice(TierPrice tierPrice) { if (tierPrice == null) { throw new ArgumentNullException("tierPrice"); } _tierPriceRepository.Delete(tierPrice); //event notification _services.EventPublisher.EntityDeleted(tierPrice); }
protected void gvTierPrices_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { TierPrice tierPrice = (TierPrice)e.Row.DataItem; Button btnUpdate = e.Row.FindControl("btnUpdate") as Button; if (btnUpdate != null) { btnUpdate.CommandArgument = e.Row.RowIndex.ToString(); } } }
public TierPrice ToModel(TierPrice item) { if (item == null) { throw new ArgumentNullException(nameof(item)); } //item.Id = Id; item.Price = Price; item.Quantity = Quantity; return(item); }
public void Can_save_and_load_tierPrice() { var tierPrice = new TierPrice { Quantity = 1, Price = 2.1M, ProductVariant = GetTestProductVariant(), }; var fromDb = SaveAndLoadEntity(tierPrice); fromDb.ShouldNotBeNull(); fromDb.Quantity.ShouldEqual(1); fromDb.Price.ShouldEqual(2.1M); fromDb.ProductVariant.ShouldNotBeNull(); fromDb.ProductVariant.Name.ShouldEqual("Product variant name 1"); }
protected void btnNewTierPrice_Click(object sender, EventArgs e) { try { ProductVariant productVariant = ProductManager.GetProductVariantByID(this.ProductVariantID); if (productVariant != null) { decimal price = txtNewPrice.Value; int quantity = txtNewQuantity.Value; TierPrice tierPrice = ProductManager.InsertTierPrice(productVariant.ProductVariantID, quantity, price); BindData(); } } catch (Exception exc) { ProcessException(exc); } }
protected void lvTierPrices_ItemDataBound(object sender, ListViewItemEventArgs e) { if (e.Item.ItemType == ListViewItemType.DataItem) { ListViewDataItem currentItem = (ListViewDataItem)e.Item; TierPrice tierPrice = currentItem.DataItem as TierPrice; ProductVariant productVariant = tierPrice.ProductVariant; Label lblQuantity = (Label)currentItem.FindControl("lblQuantity"); Label lblPrice = (Label)currentItem.FindControl("lblPrice"); decimal priceBase = TaxManager.GetPrice(productVariant, tierPrice.Price); decimal price = CurrencyManager.ConvertCurrency(priceBase, CurrencyManager.PrimaryStoreCurrency, NopContext.Current.WorkingCurrency); string priceStr = PriceHelper.FormatPrice(price, false, false); lblQuantity.Text = string.Format(GetLocaleResourceString("Products.TierPricesQuantityFormat"), tierPrice.Quantity); lblPrice.Text = priceStr; } }
public void Can_save_and_load_tierPrice() { var tierPrice = new TierPrice { StoreId = 7, Quantity = 1, Price = 2.1M, Product = GetTestProduct() }; var fromDb = SaveAndLoadEntity(tierPrice); fromDb.ShouldNotBeNull(); fromDb.StoreId.ShouldEqual(7); fromDb.Quantity.ShouldEqual(1); fromDb.Price.ShouldEqual(2.1M); fromDb.Product.ShouldNotBeNull(); }
public void Can_save_and_load_tierPrice() { var tierPrice = new TierPrice { StoreId = 7, Quantity = 1, Price = 2.1M, StartDateTimeUtc = new DateTime(2010, 01, 03), Product = GetTestProduct(), }; var fromDb = SaveAndLoadEntity(tierPrice); fromDb.ShouldNotBeNull(); fromDb.StoreId.ShouldEqual(7); fromDb.Quantity.ShouldEqual(1); fromDb.Price.ShouldEqual(2.1M); fromDb.StartDateTimeUtc.ShouldEqual(new DateTime(2010, 01, 03)); fromDb.Product.ShouldNotBeNull(); }