/// <summary> /// 新增 /// </summary> /// <param name="entity"></param> public void OriginAdd(ProductOrigin entity) { Song.Entities.Organization org = Business.Do <IOrganization>().OrganCurrent(); if (org != null) { entity.Org_ID = org.Org_ID; entity.Org_Name = org.Org_Name; } Gateway.Default.Save <ProductOrigin>(entity); }
public void Should_ParseProductCorrectly(string input, ProductOrigin expectedOrigin, string expectedDescription, decimal expectedPrice, int expectedQuantity) { using (new CultureOverride(CultureInfo.InvariantCulture)) { // Arrange var productParser = new ProductParser(); // Act var result = productParser.TryParse(input, out Product product); // Assert Assert.True(result); Assert.Equal(expectedOrigin, product.Origin); Assert.Equal(expectedDescription, product.Description); Assert.Equal(expectedQuantity, product.Quantity); Assert.Equal(expectedPrice, product.Price); Assert.Equal(expectedPrice * expectedQuantity, product.Amount); } }
public void AddItem() { Console.Clear(); _taxesPercentage = 0; Console.WriteLine("Come si chiama il prodotto che vuoi aggiungere?"); string _name = Console.ReadLine(); Console.WriteLine("Quanto costa il prodotto?"); string _priceChoice = Console.ReadLine(); float.TryParse(_priceChoice, NumberStyles.Any, _marketCurrency, out _price); if (_price > 0 && _price < 1000) { _price = Truncate(_price, 2); } else { ErrorMessage.Instance.InputError(PageType.ProductSelection); } Console.WriteLine("Da dove viene il prodotto?\n" + "1)Importato\n" + "2)Nazionale"); int _importationInput = 0; string _importationChoice = Console.ReadLine(); Int32.TryParse(_importationChoice, out _importationInput); ProductOrigin _origin = ProductOrigin.Imported; if (_importationInput == 1) { _origin = ProductOrigin.Imported; _taxesPercentage += 5; } else if (_importationInput == 2) { _origin = ProductOrigin.Home; } else { ErrorMessage.Instance.InputError(PageType.ProductSelection); } Console.WriteLine("Qual è la tipologia del prodotto?\n" + "1)Generico\n" + "2)Editoria\n" + "3)Cibo & Bevande\n" + "4)Medicinale\n"); int _productTypeInput = 0; string _productTypeChoice = Console.ReadLine(); Int32.TryParse(_productTypeChoice, out _productTypeInput); ProductType _type = ProductType.General; if (_productTypeInput == 1) { _type = ProductType.General; _taxesPercentage += 10; } else if (_productTypeInput == 2) { _type = ProductType.Books; } else if (_productTypeInput == 3) { _type = ProductType.Food; } else if (_productTypeInput == 4) { _type = ProductType.Medical; } else { ErrorMessage.Instance.InputError(PageType.ProductSelection); } Console.WriteLine("Quanti " + _name + " vuoi acquistare? (da 1 a 99)"); int _quantityNumberInput = 0; string _quantityNumberChoice = Console.ReadLine(); Int32.TryParse(_quantityNumberChoice, out _quantityNumberInput); if (_quantityNumberInput < 1 || _quantityNumberInput > 99) { ErrorMessage.Instance.InputError(PageType.ProductSelection); } float _itemTaxes = (_price / 100) * _taxesPercentage; _itemTaxes = Truncate(_itemTaxes, 2); _productList.Add(new Product(_quantityNumberInput, _name, _price, _itemTaxes, _type, _origin)); _ContinueList(); }
public Product(int _number, string _name, float _price, float _taxes, ProductType _type, ProductOrigin _origin) { this._quantity = _number; this._productName = _name; this._productPrice = _price; this._productType = _type; this._productOrigin = _origin; this._productTaxes = _taxes; }
/// <summary> /// 修改 /// </summary> /// <param name="entity">业务实体</param> public void OriginSave(ProductOrigin entity) { Gateway.Default.Save <ProductOrigin>(entity); }