private void CalculateWarePrice(UIModelWare ware) { try { if (ware.Ware1 != null) { var match = this.UIModelWares.FirstOrDefault(X => X.Name == ware.Ware1); ware.CalculatedPrice = ware.CalculatedPrice + match.Avg * ware.Amount1; } if (ware.Ware2 != null) { var match = this.UIModelWares.FirstOrDefault(X => X.Name == ware.Ware2); ware.CalculatedPrice = ware.CalculatedPrice + match.Avg * ware.Amount2; } if (ware.Ware3 != null) { var match = this.UIModelWares.FirstOrDefault(X => X.Name.Equals(ware.Ware3)); ware.CalculatedPrice = ware.CalculatedPrice + match.Avg * ware.Amount3; } if (ware.Ware4 != null) { var match = this.UIModelWares.FirstOrDefault(X => X.Name == ware.Ware4); ware.CalculatedPrice = ware.CalculatedPrice + match.Avg * ware.Amount4; } if (ware.Ware5 != null) { var match = this.UIModelWares.FirstOrDefault(X => X.Name == ware.Ware5); ware.CalculatedPrice = ware.CalculatedPrice + match.Avg * ware.Amount5; } if (ware.Amount > 1) { ware.CalculatedPrice = ware.CalculatedPrice / ware.Amount; } SetPriceOnModule(ware); } catch (Exception ex) { //MessageBox.Show("Cant calculate price for ware: " + ware.Name); ware.CalculatedPrice = 0; //throw new Exception("Cant calculate price for ware: " + ware.Name); } }
private void SetPriceOnModule(UIModelWare item) { var ship = this.UIModelShips.FirstOrDefault(x => x.Name == item.Component); if (ship != null) { ship.Price = item.Avg; } else { var shield = this.UIModelShields.FirstOrDefault(x => x.Name == item.Component); if (shield != null) { shield.Price = item.Avg; } else { var engine = this.UIModelEngines.FirstOrDefault(x => x.Name == item.Component); if (engine != null) { engine.Price = item.Avg; } else { var weapon = this.UIModelWeapons.FirstOrDefault(x => x.Name == item.Component); if (weapon != null) { weapon.Price = item.Avg; } else { var missile = this.UIModelMissiles.FirstOrDefault(x => x.Name == item.Component); if (missile != null) { missile.Price = item.Avg; } } } } } }
private bool FilterWaresData(object item) { UIModelWare ware = item as UIModelWare; if (Wares) { if ((Size_S && ware.Size == "S") || (m_Size_M && ware.Size == "M") || (m_Size_L && ware.Size == "L") || (m_Size_XL && ware.Size == "XL") || (m_Size_Other && (ware.Size != "S" && ware.Size != "M" && ware.Size != "L" && ware.Size != "XL"))) { List <string> searchArray = new List <string>(); List <string> searchArrayExceptNegatives = new List <string>(); if (this.SearchText != null && this.SearchText.Length > 0) { searchArray = this.SearchText.Split(' ').ToList(); searchArrayExceptNegatives = searchArray.Where(x => !x.StartsWith("-")).ToList(); } // filter entered if (searchArray.Count > 0) { bool found = false; foreach (string searchString in searchArray) { if (searchString.Length > 0) { if (searchString.StartsWith("-")) { if (ware.Name.ToUpper().Contains(searchString.Replace("-", "").ToUpper())) { return(false); } } if (searchArrayExceptNegatives.Count == 0 || ware.Name.ToUpper().Contains(searchString.ToUpper())) { found = true; } } } return(found); } return(true); } return(false); } else { bool found = false; foreach (var s in m_ShipsDataView) { UIModelShip ship = s as UIModelShip; if (ship != null && ship.Name.Contains(ware.Name)) { return(true); } } foreach (var e in m_EnginesDataView) { UIModelEngine engine = e as UIModelEngine; if (engine != null && engine.Name.Contains(ware.Name)) { return(true); } } foreach (var s in m_ShieldsDataView) { UIModelShield shield = s as UIModelShield; if (shield != null && shield.Name.Contains(ware.Name)) { return(true); } } foreach (var p in m_ProjectilesDataView) { UIModelProjectile weapon = p as UIModelProjectile; if (weapon != null && weapon.Name.Contains(ware.Name)) { return(true); } } foreach (var w in m_WeaponsDataView) { UIModelWeapon weapon = w as UIModelWeapon; if (weapon != null && weapon.Name.Contains(ware.Name)) { return(true); } } foreach (var w in m_ProjectilesDataView) { UIModelWeapon weapon = w as UIModelWeapon; if (weapon != null && weapon.Name.Contains(ware.Name)) { return(true); } } foreach (var m in m_MissilesDataView) { UIModelMissile missile = m as UIModelMissile; if (missile != null && missile.Name.Contains(ware.Name)) { return(true); } } return(found); } }