예제 #1
0
        public ConfigurationOverviewViewModel CreateConfigurationOverviewViewModel(ConfigurationViewModel configuration)
        {
            var rimsLabel       = Display.GetValue(_ => _.Name, _dbContext.FindRimsById(configuration.RimsValue));
            var varnishLabel    = Display.GetValue(_ => _.Name, _dbContext.FindVarnishById(configuration.VarnishValue));
            var equipmentLabels = _dbContext.FindEquipmentsByIds(configuration.EquipmentValues).Select(equipment => Display.GetValue(_ => _.Name, equipment)).ToList();

            return(new ConfigurationOverviewViewModel {
                Name = configuration.Name,
                Email = configuration.Email,
                Price = configuration.Price,
                EnginePower = configuration.EnginePower,
                RimsLabel = rimsLabel,
                VarnishLabel = varnishLabel,
                EquipmentLabels = equipmentLabels,
            });
        }
        public JsonResult Update(string propertyName, object newValue)
        {
            try {
                var configuration = Session[Constants.ConfigurationSessionKey] as ConfigurationViewModel;
                _updateService.Update(configuration, propertyName, newValue);

                var equipments = _dbContext.FindEquipmentsByIds(configuration.EquipmentValues);
                var rims       = _dbContext.FindRimsById(configuration.RimsValue);
                var varnish    = _dbContext.FindVarnishById(configuration.VarnishValue);

                configuration.Price = _priceCalculationService.CalculatePrice(GetCurrency(), equipments, rims, varnish, configuration.EnginePower);

                return(Json(new { configuration.PriceLabel }));
            }
            catch (Exception e) {
                Logger.Error(e);
                return(Json(new { Error = KonfiguratorResx.Error_UpdateFailed }));
            }
        }