public ShoppingListItemContract ToContract(ShoppingListItemReadModel source) { if (source is null) { throw new System.ArgumentNullException(nameof(source)); } ItemCategoryContract itemCategoryContract = null; if (source.ItemCategory != null) { itemCategoryContract = itemCategoryContractConverter.ToContract(source.ItemCategory); } ManufacturerContract manufacturerContract = null; if (source.Manufacturer != null) { manufacturerContract = manufacturerContractConverter.ToContract(source.Manufacturer); } QuantityTypeContract quantityTypeContract = quantityTypeContractConverter.ToContract(source.QuantityType); QuantityTypeInPacketContract quantityTypeInPacketContract = quantityTypeInPacketContractConverter.ToContract(source.QuantityTypeInPacket); return(new ShoppingListItemContract( source.Id.Value, source.Name, source.IsDeleted, source.Comment, source.IsTemporary, source.PricePerQuantity, quantityTypeContract, source.QuantityInPacket, quantityTypeInPacketContract, itemCategoryContract, manufacturerContract, source.IsInBasket, source.Quantity)); }
public StoreItemContract(int id, string name, bool isDeleted, string comment, bool isTemporary, QuantityTypeContract quantityType, float quantityInPacket, QuantityTypeInPacketContract quantityTypeInPacket, ItemCategoryContract itemCategory, ManufacturerContract manufacturer, IEnumerable <StoreItemAvailabilityContract> availabilities) { if (string.IsNullOrEmpty(name)) { throw new System.ArgumentException($"'{nameof(name)}' cannot be null or empty", nameof(name)); } Id = id; Name = name; IsDeleted = isDeleted; Comment = comment; IsTemporary = isTemporary; QuantityType = quantityType ?? throw new System.ArgumentNullException(nameof(quantityType)); QuantityInPacket = quantityInPacket; QuantityTypeInPacket = quantityTypeInPacket ?? throw new System.ArgumentNullException(nameof(quantityTypeInPacket)); ItemCategory = itemCategory; Manufacturer = manufacturer; this.availabilities = availabilities ?? throw new System.ArgumentNullException(nameof(availabilities)); }
private void btnContract_Click(object sender, RoutedEventArgs e) { Boolean newContract = true; if (GameObject.GetInstance().HumanAirline.Contract != null) { if (GameObject.GetInstance().HumanAirline.Contract.Manufacturer == this.Manufacturer && GameObject.GetInstance().HumanAirline.Contract.Length < 15) { WPFMessageBoxResult result = WPFMessageBox.Show(Translator.GetInstance().GetString("MessageBox", "2011"), string.Format(Translator.GetInstance().GetString("MessageBox", "2011", "message"), GameObject.GetInstance().HumanAirline.Contract.Manufacturer.Name), WPFMessageBoxButtons.YesNo); if (result == WPFMessageBoxResult.Yes) { ComboBox cbLength = new ComboBox(); cbLength.SetResourceReference(ComboBox.StyleProperty, "ComboBoxTransparentStyle"); cbLength.HorizontalAlignment = System.Windows.HorizontalAlignment.Left; cbLength.Width = 200; cbLength.Items.Add(createLengthItem(3)); cbLength.Items.Add(createLengthItem(5)); cbLength.Items.Add(createLengthItem(7)); cbLength.Items.Add(createLengthItem(10)); cbLength.SelectedIndex = 0; if (PopUpSingleElement.ShowPopUp(Translator.GetInstance().GetString("PageOrderAirliners", "1010"), cbLength) == PopUpSingleElement.ButtonSelected.OK) { int nLength = (int)((ComboBoxItem)cbLength.SelectedItem).Tag; int length = GameObject.GetInstance().HumanAirline.Contract.Length + nLength; double discount = AirlineHelpers.GetAirlineManufactorerDiscountFactor(GameObject.GetInstance().HumanAirline, length, true); GameObject.GetInstance().HumanAirline.Contract.Length = length; GameObject.GetInstance().HumanAirline.Contract.Discount = discount; GameObject.GetInstance().HumanAirline.Contract.Airliners = length; GameObject.GetInstance().HumanAirline.Contract.ExpireDate = GameObject.GetInstance().HumanAirline.Contract.ExpireDate.AddYears(nLength); } } newContract = false; } else { double terminationFee = GameObject.GetInstance().HumanAirline.Contract.getTerminationFee(); WPFMessageBoxResult result = WPFMessageBox.Show(Translator.GetInstance().GetString("MessageBox", "2010"), string.Format(Translator.GetInstance().GetString("MessageBox", "2010", "message"), GameObject.GetInstance().HumanAirline.Contract.Manufacturer.Name, terminationFee), WPFMessageBoxButtons.YesNo); if (result == WPFMessageBoxResult.Yes) { AirlineHelpers.AddAirlineInvoice(GameObject.GetInstance().HumanAirline, GameObject.GetInstance().GameTime, Invoice.InvoiceType.Purchases, -terminationFee); GameObject.GetInstance().HumanAirline.Contract = null; } else { newContract = false; } } } if (newContract) { ComboBox cbLength = new ComboBox(); cbLength.SetResourceReference(ComboBox.StyleProperty, "ComboBoxTransparentStyle"); cbLength.HorizontalAlignment = System.Windows.HorizontalAlignment.Left; cbLength.Width = 200; cbLength.Items.Add(createLengthItem(3)); cbLength.Items.Add(createLengthItem(5)); cbLength.Items.Add(createLengthItem(7)); cbLength.Items.Add(createLengthItem(10)); cbLength.SelectedIndex = 0; if (PopUpSingleElement.ShowPopUp(Translator.GetInstance().GetString("PageOrderAirliners", "1011"), cbLength) == PopUpSingleElement.ButtonSelected.OK) { int length = (int)((ComboBoxItem)cbLength.SelectedItem).Tag; double discount = AirlineHelpers.GetAirlineManufactorerDiscountFactor(GameObject.GetInstance().HumanAirline, length, true); ManufacturerContract contract = new ManufacturerContract(this.Manufacturer, GameObject.GetInstance().GameTime, length, discount); GameObject.GetInstance().HumanAirline.Contract = contract; } } this.ParentPage.updatePage(); }