public void PriceForQuantity_OnItemQuantitySameAsThreshold_ShouldReturnDiscoutedPricing() { var decorator = new SalePrice(_testItem, 1, 50); var expectedPricingInCents = 50 * 1; //1 apple in discount price Assert.AreEqual(expectedPricingInCents, decorator.GetEffectivePrice(1)); }
public void PriceForQuantity_OnItemQuantityAboveEligibleThreshold_ShouldReturnDiscountedPricing() { var decorator = new SalePrice(_testItem, 1, 50); var expectedPricingInCents = 50 * 2; //2 apples in discount price Assert.AreEqual(expectedPricingInCents, decorator.GetEffectivePrice(2)); }
public override void UploadToDatabase() { string sql = $"INSERT INTO `service_products` (`id`, `name`, `price`, `group_price`, `group_limit`, `groups`)" + $"VALUES (NULL, '{Name}', '{SalePrice.ToString().Replace(',', '.')}','{GroupPrice.ToString().Replace(',', '.')}','{GroupLimit}','{ServiceProductGroupID}');"; Mysql.RunQuery(sql); }
public override void UploadToDatabase() { string sql = "INSERT INTO `temp_products` (`id`, `sale_price`, `description`, `resolved`, `resolved_product_id`)" + $"VALUES (NULL, '{SalePrice.ToString().Replace(',', '.')}', '{GetName()}', '{Convert.ToInt32(Resolved)}', '{ResolvedProductID}');"; Mysql.RunQuery(sql); }
private void CostPrice_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { SalePrice.Focus(); } }
public void PriceForQuantity_OnItemQuantityLessThanEligibleThreshold_ShouldReturnActualPricing() { var decorator = new SalePrice(_testItem, 3, 50); var expectedPricingInCents = 75 * 2; //2 apples in actual price Assert.AreEqual(expectedPricingInCents, decorator.GetEffectivePrice(2)); }
public override string ToString() { input = new ProductController(); return("ID: " + input.toScreen(ID.ToString(), 4) + " | Name: " + input.toScreen(Name, 20) + " | Quantidade: " + input.toScreen(Quantity.ToString(), 4) + " | Valor Unitário: R$" + input.toScreen(SalePrice.ToString("F2"), 10)); }
public override void UploadToDatabase() { string sql = $"INSERT INTO `products` (`id`, `name`, `brand`, `groups`, `price`, `purchase_price` ,`discount`, `discount_price`)" + $" VALUES (NULL, '{Name}', '{Brand}', '{ProductGroupID}', '{SalePrice.ToString().Replace(',', '.')}','{PurchasePrice.ToString().Replace(',', '.')}', '{Convert.ToInt32(DiscountBool)}', '{DiscountPrice.ToString().Replace(',', '.')}');"; Mysql.RunQuery(sql); UpdateStorageStatus(); CreatedTime = DateTime.Now; }
protected void textBoxProductID_TextChanged(object sender, EventArgs e) { string ProductID = textBoxProductID.Text; string Name = ""; string Description = ""; decimal Price; decimal SalePrice; int InSale; int Quantity; string CategoryName = ""; string SubCategoryName = ""; string Color = ""; string Weight = ""; //int ProductStatus; Products prodObj = new Products(); prodObj.fnGetProductDetails(ProductID, out Name, out Description, out Price, out SalePrice, out InSale, out Quantity, out CategoryName, out SubCategoryName, out Color, out Weight); //out ProductStatus); textBoxAddProductName.Text = Name; textBoxAddProductDescription.Text = Description; textBoxAddProductPrice.Text = Price.ToString(); textBoxAddProductSalePrice.Text = SalePrice.ToString(); textBoxProductQuantity.Text = Quantity.ToString(); textBoxAddProductColor.Text = Color; dropDownAddCategory.Text = CategoryName; textBoxAddProductWeight.Text = Weight; Session["ProductID"] = textBoxProductID.Text; Session["ProductName"] = textBoxAddProductName.Text; Session["ProductDescription"] = textBoxAddProductDescription.Text; Session["ProductCategory"] = dropDownAddCategory.SelectedItem; Session["ProductSubCategory"] = SubCategoryName; Session["ProductPrice"] = Convert.ToDouble(textBoxAddProductPrice.Text); Session["ProductSalePrice"] = Convert.ToDouble(textBoxAddProductSalePrice.Text); Session["ProductQuantity"] = Convert.ToInt32(textBoxProductQuantity.Text); Session["ProductColor"] = textBoxAddProductColor.Text; Session["ProductWeight"] = textBoxAddProductWeight.Text; if (InSale == 1) { checkBoxInSale.Checked = true; } else { checkBoxInSale.Checked = false; } dropDownAddCategory.SelectedValue = Session["ProductCategory"].ToString(); dropDownAddCategory_SelectedIndexChanged(this.dropDownAddCategory, EventArgs.Empty); }
public override void UpdateInDatabase() { string sql = $"UPDATE `temp_products` SET " + $"`sale_price` = '{SalePrice.ToString().Replace(',', '.')}'," + $"`description` = '{GetName()}'," + $"`resolved` = '{Convert.ToInt32(Resolved)}'," + $"`resolved_product_id` = '{ResolvedProductID}' " + $"WHERE `id` = {ID};"; Mysql.RunQuery(sql); }
/// <summary> /// Convert current product price to other currency using currency exchange rate /// </summary> /// <param name="currency"></param> /// <returns></returns> public ProductPrice ConvertTo(Currency currency) { var retVal = new ProductPrice(currency); retVal.ListPrice = ListPrice.ConvertTo(currency); retVal.SalePrice = SalePrice.ConvertTo(currency); retVal.DiscountAmount = DiscountAmount.ConvertTo(currency); retVal.ProductId = ProductId; return(retVal); }
public override object Clone() { var result = MemberwiseClone() as ProductPrice; result.Currency = Currency?.Clone() as Currency; result.DiscountAmount = DiscountAmount?.Clone() as Money; result.ListPrice = ListPrice?.Clone() as Money; result.SalePrice = SalePrice?.Clone() as Money; result.TierPrices = TierPrices?.Select(x => x.Clone() as TierPrice).ToList(); result.Discounts = Discounts?.Select(x => x.Clone() as Discount).ToList(); return(result); }
public override void UpdateInDatabase() { string sql = $"UPDATE `service_products` SET " + $"`name` = '{Name}'," + $"`price` = '{SalePrice.ToString().Replace(',', '.')}'," + $"`group_price` = '{GroupPrice.ToString().Replace(',', '.')}'," + $"`group_limit` = '{GroupLimit}'," + $"`active` = '{Convert.ToInt32(_active)}'," + $"`groups` = '{ServiceProductGroupID}' " + $"WHERE `id` = {ID};"; Mysql.RunQuery(sql); }
private static async Task UpdateSalePrice(int id, SalePrice salePrice) { var client = new HttpClient(); client.BaseAddress = new Uri(savePriceUrl); var content = new StringContent(JsonConvert.SerializeObject(salePrice), Encoding.UTF8, "application/json"); var response = await client.PutAsync(string.Empty + id, content); if (!response.IsSuccessStatusCode) { Console.WriteLine("Update sale price failed for ID " + id + " with error " + response.ReasonPhrase); } }
public void CreateCart_ForValidInput_ShouldReturnExpectedPromoDecoratedItems() { Cart cart = _cartFactory.CreateCart(GetTestOrdersStream(), TEST_ORDER_DATE); Assert.IsTrue(cart.GetOrderItems().Count == 2, "Expected 2 Cart Items"); var appleProductItem = new ProductItem("111", "APPLE", 75); var expectedDecoratedItem = new SalePrice(appleProductItem, 1, 50); Assert.IsTrue( cart.GetOrderItems() .Any(keyValue => keyValue.Key.Equals(expectedDecoratedItem) && keyValue.Value.Equals(7)), "Card Items didn't match expected ProductItem: " + appleProductItem); }
public override void UpdateInDatabase() { string sql = $"UPDATE `products` SET " + $"`name` = '{GetName()}'," + $"`brand` = '{Brand}'," + $"`groups` = '{ProductGroupID}'," + $"`price` = '{SalePrice.ToString().Replace(',', '.')}'," + $"`discount` = '{Convert.ToInt32(DiscountBool)}'," + $"`discount_price` = '{DiscountPrice.ToString().Replace(',', '.')}'," + $"`purchase_price` = '{PurchasePrice.ToString().Replace(',', '.')}' " + $"WHERE `id` = {ID};"; Mysql.RunQuery(sql); UpdateStorageStatus(); }
/// <summary> /// Convert current product price to other currency using currency exchange rate /// </summary> /// <param name="currency"></param> /// <returns></returns> public ProductPrice ConvertTo(Currency currency) { var retVal = new ProductPrice(currency); retVal.ListPrice = ListPrice.ConvertTo(currency); retVal.SalePrice = SalePrice.ConvertTo(currency); retVal.ProductId = ProductId; if (ActiveDiscount != null) { retVal.ActiveDiscount = ActiveDiscount.ConvertTo(currency); } if (PotentialDiscount != null) { retVal.PotentialDiscount = PotentialDiscount.ConvertTo(currency); } return(retVal); }
public override object Clone() { var result = (ConfiguredGroup)base.Clone(); result.ListPrice = ListPrice?.Clone() as Money; result.SalePrice = SalePrice?.Clone() as Money; result.ListPriceWithTax = ListPriceWithTax?.Clone() as Money; result.SalePriceWithTax = SalePriceWithTax?.Clone() as Money; result.PlacedPrice = PlacedPrice?.Clone() as Money; result.PlacedPriceWithTax = PlacedPriceWithTax?.Clone() as Money; result.ExtendedPrice = ExtendedPrice?.Clone() as Money; result.ExtendedPriceWithTax = ExtendedPriceWithTax?.Clone() as Money; result.TaxTotal = TaxTotal?.Clone() as Money; result.Items = new List <LineItem>(); return(result); }
public override int GetHashCode() { unchecked { var hashCode = Attributes != null?Attributes.GetHashCode() : 0; hashCode = (hashCode * 397) ^ (CatalogVisibility != null ? CatalogVisibility.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (Categories != null ? Categories.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (Description != null ? Description.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (ExternalUrl != null ? ExternalUrl.GetHashCode() : 0); hashCode = (hashCode * 397) ^ Featured.GetHashCode(); hashCode = (hashCode * 397) ^ Id; hashCode = (hashCode * 397) ^ (Images != null ? Images.GetHashCode() : 0); hashCode = (hashCode * 397) ^ InStock.GetHashCode(); hashCode = (hashCode * 397) ^ ManageStock.GetHashCode(); hashCode = (hashCode * 397) ^ (Name != null ? Name.GetHashCode() : 0); hashCode = (hashCode * 397) ^ OnSale.GetHashCode(); hashCode = (hashCode * 397) ^ ParentId; hashCode = (hashCode * 397) ^ (Permalink != null ? Permalink.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (Price != null ? Price.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (PriceHtml != null ? PriceHtml.GetHashCode() : 0); hashCode = (hashCode * 397) ^ Purchasable.GetHashCode(); hashCode = (hashCode * 397) ^ (RegularPrice != null ? RegularPrice.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (RelatedIds != null ? RelatedIds.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (SalePrice != null ? SalePrice.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (ShortDescription != null ? ShortDescription.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (Sku != null ? Sku.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (Slug != null ? Slug.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (Status != null ? Status.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (StockQuantity != null ? StockQuantity.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (Tags != null ? Tags.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (TaxClass != null ? TaxClass.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (TaxStatus != null ? TaxStatus.GetHashCode() : 0); hashCode = (hashCode * 397) ^ TotalSales; hashCode = (hashCode * 397) ^ (Type != null ? Type.GetHashCode() : 0); hashCode = (hashCode * 397) ^ Virtual.GetHashCode(); return(hashCode); } }
public override object Clone() { var result = base.Clone() as LineItem; result.ListPrice = ListPrice?.Clone() as Money; result.SalePrice = SalePrice?.Clone() as Money; result.DiscountAmount = DiscountAmount?.Clone() as Money; result.DiscountAmountWithTax = DiscountAmountWithTax?.Clone() as Money; result.DiscountTotal = DiscountTotal?.Clone() as Money; result.DiscountTotalWithTax = DiscountTotalWithTax?.Clone() as Money; result.ListPriceWithTax = ListPriceWithTax?.Clone() as Money; result.SalePriceWithTax = SalePriceWithTax?.Clone() as Money; result.PlacedPrice = PlacedPrice?.Clone() as Money; result.PlacedPriceWithTax = PlacedPriceWithTax?.Clone() as Money; result.ExtendedPrice = ExtendedPrice?.Clone() as Money; result.ExtendedPriceWithTax = ExtendedPriceWithTax?.Clone() as Money; result.TaxTotal = TaxTotal?.Clone() as Money; if (Discounts != null) { result.Discounts = new List <Discount>(Discounts.Select(x => x.Clone() as Discount)); } if (TaxDetails != null) { result.TaxDetails = new List <TaxDetail>(TaxDetails.Select(x => x.Clone() as TaxDetail)); } if (DynamicProperties != null) { result.DynamicProperties = new MutablePagedList <DynamicProperty>(DynamicProperties.Select(x => x.Clone() as DynamicProperty)); } if (ValidationErrors != null) { result.ValidationErrors = new List <ValidationError>(ValidationErrors.Select(x => x.Clone() as ValidationError)); } return(result); }
public void Put(int id, [FromBody] SalePrice value) { }
public string SearchQuery() { return(CurrentPrice.ToString() + "/" + SalePrice.ToString() + "/" + RegularPrice.ToString() + "/" + (IsOnSale ? "sale" : "not")); }
protected bool Equals(SalePrice other) { return(GetOrderItem().Equals(other.GetOrderItem()) && _thresholdQuantity == other._thresholdQuantity && _salePriceInCents == other._salePriceInCents); }
public override string ToString() => $"{Quantity} @ {SalePrice.ToCurrency(2)} on {SaleDate.ToShortDateString()}";
protected void textBoxProductID_TextChanged(object sender, EventArgs e) { string ProductID = textBoxProductID.Text; string Name = ""; string Description = ""; decimal Price; decimal SalePrice; int InSale; int Quantity; string CategoryName = ""; string SubCategoryName = ""; string Color = ""; string Weight = ""; //int ProductStatus; try { Products prodObj = new Products(); prodObj.fnGetProductDetails(ProductID, out Name, out Description, out Price, out SalePrice, out InSale, out Quantity, out CategoryName, out SubCategoryName, out Color, out Weight); //out ProductStatus); Session["ProductCategory"] = CategoryName; if (Name != null) { textBoxAddProductName.Text = Name; } if (Description != null) { textBoxAddProductDescription.Text = Description; } textBoxAddProductPrice.Text = Price.ToString(); textBoxAddProductSalePrice.Text = SalePrice.ToString(); textBoxProductQuantity.Text = Quantity.ToString(); if (Color != null) { textBoxAddProductColor.Text = Color; } if (CategoryName != null) { dropDownAddCategory.Text = CategoryName; } if (Weight != null) { textBoxAddProductWeight.Text = Weight; } Session["ProductID"] = textBoxProductID.Text; Session["ProductName"] = textBoxAddProductName.Text; Session["ProductDescription"] = textBoxAddProductDescription.Text; Session["ProductCategory"] = dropDownAddCategory.SelectedItem; Session["ProductSubCategory"] = SubCategoryName.ToString(); Session["ProductPrice"] = Convert.ToDouble(textBoxAddProductPrice.Text); Session["ProductSalePrice"] = Convert.ToDouble(textBoxAddProductSalePrice.Text); Session["ProductQuantity"] = Convert.ToInt32(textBoxProductQuantity.Text); Session["ProductColor"] = textBoxAddProductColor.Text; Session["ProductWeight"] = textBoxAddProductWeight.Text; if (InSale == 1) { checkBoxInSale.Checked = true; } else { checkBoxInSale.Checked = false; textBoxAddProductSalePrice.Enabled = false; } dropDownAddCategory.Text = Session["ProductCategory"].ToString(); dropDownAddCategory_SelectedIndexChanged(this.dropDownAddCategory, EventArgs.Empty); } catch (Exception ex) { Response.Write("<SCRIPT LANGUAGE='JavaScript'>alert('" + ex.Message + "')</SCRIPT>"); Response.Redirect("Error.aspx"); } }
public Schema() : base() { InstanceType = typeof(__HousesVi__); Properties.ClearExposed(); Html = Add <__TString__>("Html"); Html.DefaultValue = "/Noman/HousesView.html"; Html.SetCustomAccessors((_p_) => { return(((__HousesVi__)_p_).__bf__Html__); }, (_p_, _v_) => { ((__HousesVi__)_p_).__bf__Html__ = (System.String)_v_; }, false); url = Add <__TString__>("url", bind: "url"); url.DefaultValue = ""; url.SetCustomAccessors((_p_) => { return(((__HousesVi__)_p_).__bf__url__); }, (_p_, _v_) => { ((__HousesVi__)_p_).__bf__url__ = (System.String)_v_; }, false); House_No = Add <__TString__>("House_No$"); House_No.DefaultValue = ""; House_No.Editable = true; House_No.SetCustomAccessors((_p_) => { return(((__HousesVi__)_p_).__bf__House_No__); }, (_p_, _v_) => { ((__HousesVi__)_p_).__bf__House_No__ = (System.String)_v_; }, false); Street = Add <__TString__>("Street$"); Street.DefaultValue = ""; Street.Editable = true; Street.SetCustomAccessors((_p_) => { return(((__HousesVi__)_p_).__bf__Street__); }, (_p_, _v_) => { ((__HousesVi__)_p_).__bf__Street__ = (System.String)_v_; }, false); ZipCode = Add <__TString__>("ZipCode$"); ZipCode.DefaultValue = ""; ZipCode.Editable = true; ZipCode.SetCustomAccessors((_p_) => { return(((__HousesVi__)_p_).__bf__ZipCode__); }, (_p_, _v_) => { ((__HousesVi__)_p_).__bf__ZipCode__ = (System.String)_v_; }, false); City = Add <__TString__>("City$"); City.DefaultValue = ""; City.Editable = true; City.SetCustomAccessors((_p_) => { return(((__HousesVi__)_p_).__bf__City__); }, (_p_, _v_) => { ((__HousesVi__)_p_).__bf__City__ = (System.String)_v_; }, false); State = Add <__TString__>("State$"); State.DefaultValue = ""; State.Editable = true; State.SetCustomAccessors((_p_) => { return(((__HousesVi__)_p_).__bf__State__); }, (_p_, _v_) => { ((__HousesVi__)_p_).__bf__State__ = (System.String)_v_; }, false); Country = Add <__TString__>("Country$"); Country.DefaultValue = ""; Country.Editable = true; Country.SetCustomAccessors((_p_) => { return(((__HousesVi__)_p_).__bf__Country__); }, (_p_, _v_) => { ((__HousesVi__)_p_).__bf__Country__ = (System.String)_v_; }, false); TransactionTime = Add <__TString__>("TransactionTime$"); TransactionTime.DefaultValue = ""; TransactionTime.Editable = true; TransactionTime.SetCustomAccessors((_p_) => { return(((__HousesVi__)_p_).__bf__TransactionTime__); }, (_p_, _v_) => { ((__HousesVi__)_p_).__bf__TransactionTime__ = (System.String)_v_; }, false); SalePrice = Add <__TLong__>("SalePrice$"); SalePrice.DefaultValue = 0L; SalePrice.Editable = true; SalePrice.SetCustomAccessors((_p_) => { return(((__HousesVi__)_p_).__bf__SalePrice__); }, (_p_, _v_) => { ((__HousesVi__)_p_).__bf__SalePrice__ = (System.Int64)_v_; }, false); Commision = Add <__TLong__>("Commision$"); Commision.DefaultValue = 0L; Commision.Editable = true; Commision.SetCustomAccessors((_p_) => { return(((__HousesVi__)_p_).__bf__Commision__); }, (_p_, _v_) => { ((__HousesVi__)_p_).__bf__Commision__ = (System.Int64)_v_; }, false); CompleteAddress = Add <__TString__>("CompleteAddress", bind: "CompleteAddress"); CompleteAddress.DefaultValue = ""; CompleteAddress.SetCustomAccessors((_p_) => { return(((__HousesVi__)_p_).__bf__CompleteAddress__); }, (_p_, _v_) => { ((__HousesVi__)_p_).__bf__CompleteAddress__ = (System.String)_v_; }, false); Longitude = Add <__TString__>("Longitude$"); Longitude.DefaultValue = ""; Longitude.Editable = true; Longitude.SetCustomAccessors((_p_) => { return(((__HousesVi__)_p_).__bf__Longitude__); }, (_p_, _v_) => { ((__HousesVi__)_p_).__bf__Longitude__ = (System.String)_v_; }, false); Latitude = Add <__TString__>("Latitude$"); Latitude.DefaultValue = ""; Latitude.Editable = true; Latitude.SetCustomAccessors((_p_) => { return(((__HousesVi__)_p_).__bf__Latitude__); }, (_p_, _v_) => { ((__HousesVi__)_p_).__bf__Latitude__ = (System.String)_v_; }, false); latitude = Add <__TLong__>("latitude", bind: "latitude"); latitude.DefaultValue = 0L; latitude.SetCustomAccessors((_p_) => { return(((__HousesVi__)_p_).__bf__latitude__); }, (_p_, _v_) => { ((__HousesVi__)_p_).__bf__latitude__ = (System.Int64)_v_; }, false); longitude = Add <__TLong__>("longitude", bind: "longitude"); longitude.DefaultValue = 0L; longitude.SetCustomAccessors((_p_) => { return(((__HousesVi__)_p_).__bf__longitude__); }, (_p_, _v_) => { ((__HousesVi__)_p_).__bf__longitude__ = (System.Int64)_v_; }, false); RegisterHouse = Add <__TLong__>("RegisterHouse$"); RegisterHouse.DefaultValue = 0L; RegisterHouse.Editable = true; RegisterHouse.SetCustomAccessors((_p_) => { return(((__HousesVi__)_p_).__bf__RegisterHouse__); }, (_p_, _v_) => { ((__HousesVi__)_p_).__bf__RegisterHouse__ = (System.Int64)_v_; }, false); RegisterHouse.AddHandler((Json pup, Property <Int64> prop, Int64 value) => { return(new Input.RegisterHouse() { App = (HousesView)pup, Template = (TLong)prop, Value = value }); }, (Json pup, Starcounter.Input <Int64> input) => { ((HousesView)pup).Handle((Input.RegisterHouse)input); }); }