Exemple #1
0
 public ImportExport(ConfiguratorViewModel vm)
 {
     this._vm = vm;
 }
Exemple #2
0
 public NewXmlFile(ConfiguratorViewModel vm)
 {
     this._vm = vm;
 }
Exemple #3
0
 public SetAsDefault(ConfiguratorViewModel vm)
 {
     this._vm = vm;
 }
Exemple #4
0
        public ViewResult Configurator(ConfiguratorViewModel details)
        {
            if (ModelState.IsValid)
            {
                var bodiesquery = orderRepo.GetAvailableBodies();

                var dims = details.SelectedItemValue.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries);
                bodiesquery = bodiesquery
                              .Where(x => (x.Height == int.Parse(dims[0]) && x.Width == int.Parse(dims[1]) && x.Depth == int.Parse(dims[2])));
                if (details.SelectedColor != null)
                {
                    bodiesquery = bodiesquery.Where(x => x.Color == details.SelectedColor);
                }
                if (details.SelectedDoorType != null)
                {
                    bodiesquery = bodiesquery.Where(x => x.DoorType == details.SelectedDoorType);
                }
                var bodies = bodiesquery.Where(x => x.Freezer == details.Freezer).ToList();

                var compressorquery = orderRepo.Compressors;
                if (details.SelectedEnergyClass != null)
                {
                    compressorquery = orderRepo.Compressors.Where(x => x.EnergyClass == details.SelectedEnergyClass);
                }
                var compressor = compressorquery.ToList();
                var shelves    = orderRepo.Shelves.Where(x => (x.Width == int.Parse(dims[1]) && x.Depth == int.Parse(dims[2]))).ToList();
                var dictionary = new Dictionary <string, int>();
                foreach (var s in shelves)
                {
                    dictionary.Add(s.Symbol, 0);
                }
                var balconies   = orderRepo.Balconies.Where(x => (x.Width == int.Parse(dims[1]))).ToList();
                var dictionary2 = new Dictionary <string, int>();
                foreach (var b in balconies)
                {
                    dictionary2.Add(b.Symbol, 0);
                }
                var adds        = orderRepo.Additionals.ToList();
                var dictionary3 = new Dictionary <string, bool>();
                foreach (var a in adds)
                {
                    dictionary3.Add(a.Symbol, false);
                }

                return(View("Configurator2", new Configurator2ViewModel()
                {
                    Bodies = bodies.Select(n => new SelectListItem()
                    {
                        Value = n.Symbol, Text = n.Name + " | " + n.Price.ToString("c")
                    }).ToList(),
                    Compressors = compressor
                                  .Select(n => new SelectListItem()
                    {
                        Value = n.Symbol,
                        Text = n.Name + " | " + n.Power + "W" + " | " + n.Price.ToString("c")
                    }).ToList(),
                    Freezer = details.Freezer,
                    Handles = orderRepo.Handles
                              .Select(n => new SelectListItem()
                    {
                        Value = n.Symbol, Text = n.Name + " | " + n.Color + " | " + n.Price.ToString("c")
                    }).ToList(),
                    Shelves = shelves,
                    NumberOfShelves = dictionary,
                    Balconies = balconies,
                    NumberOfBalconies = dictionary2,
                    Additional = adds,
                    Additionals = dictionary3
                }));
            }
            return(View(details));
        }