Ejemplo n.º 1
0
        public ModelDetails MergeTo(ModelDetails sell)
        {
            sell.Cars = sell.Cars.Where(x => x.State != CarState.Deleted).ToArray();

            var newSelling = Selling(sell.Brand, sell.Model);

            //// Test Green
            /*var l1 = newSelling.ToList();
            l1.Add(new CarDetails(){Title = "Hellop", Href = "fedos", PricesHistrory = new List<int>(){3}});
            newSelling = l1.ToArray();*/

            //// Test Yellow
            //newSelling[0].PricesHistrory.RemoveAll(x => true);
            //newSelling[0].PricesHistrory.Add(1234);

            //// Test Red
            //var l = newSelling.ToList();
            //l.RemoveAt(1);
            //newSelling = l.ToArray();

            var previosCarsData = sell.Cars.ToDictionary(x => x.Href, y=> y);
            var newCarsData = newSelling.ToDictionary(x => x.Href, y => y);

            var newSell = from x in newSelling
                            where !previosCarsData.ContainsKey(x.Href)
                            select x;
            var priceUpdatedSell =  from x in newSelling
                                        where previosCarsData.ContainsKey(x.Href) && previosCarsData[x.Href].Price != x.Price
                                        select previosCarsData[x.Href];
            var deletedNewCell =    from x in sell.Cars
                                        where !newCarsData.ContainsKey(x.Href)
                                        select x;

            foreach (var car in sell.Cars)
                car.State = CarState.NotUpdated;
            foreach (var car in priceUpdatedSell)
            {
                car.PricesHistrory.Add(newCarsData[car.Href].Price);
                car.State = CarState.Updated;
            }
            foreach (var car in deletedNewCell)
            {
                car.State = CarState.Deleted;
            }
            var newArray = newSell.ToList();
            newArray.AddRange(sell.Cars);
            sell.Cars = newArray.ToArray();
            sell.Count = sell.Cars.Length;

            return sell;
        }
Ejemplo n.º 2
0
 private void OnClick(object sender, RoutedEventArgs e)
 {
     if (BrandComboBox.SelectedItem != null)
         if (ModelComboBox.SelectedItem != null)
         {
             ModelDetails = new ModelDetails()
                 {
                     Brand = BrandComboBox.SelectedItem.ToString(),
                     Model = ModelComboBox.SelectedItem.ToString(),
                     BrandId = brands[BrandComboBox.SelectedItem.ToString()],
                     ModelId = models[ModelComboBox.SelectedItem.ToString()],
                 };
             ModelDetails.Count = carsApi.CountPages(ModelDetails.BrandId, ModelDetails.ModelId);
             DialogResult = true;
             return;
         }
     DialogResult = false;
 }
Ejemplo n.º 3
0
 public ModelDetails MergeTo(ModelDetails sell)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 4
0
 public JsonResult MergeTo(ModelDetails sell)
 {
     return Json(carsApi.MergeTo(sell), JsonRequestBehavior.AllowGet);
 }
Ejemplo n.º 5
0
 private void EyedModelsInitListBox(ModelDetails selected)
 {
     SellingCars.ItemsSource = selected.Cars;
 }