public ConfigurationController(PriceCalculationService priceCalculationService, UpdateService updateService, OrderService orderService, KonfiguratorDbContext dbContext,
                                EmailService emailService, ViewModelService viewModelService)
 {
     _viewModelService        = viewModelService;
     _emailService            = emailService;
     _priceCalculationService = priceCalculationService;
     _dbContext     = dbContext;
     _orderService  = orderService;
     _updateService = updateService;
 }
示例#2
0
        public ConfigurationViewModel CreateConfigurationViewModel(KonfiguratorDbContext dbContext)
        {
            var viewModel = new ConfigurationViewModel {
                EnginePower      = 50,
                EquipmentValues  = new List <int>(),
                EquipmentOptions = new List <SelectOption>(),
                VarnishOptions   = new List <SelectOption>(),
                RimsOptions      = new List <SelectOption>()
            };

            foreach (var equipment in dbContext.Equipments)
            {
                viewModel.EquipmentOptions.Add(new SelectOption {
                    Label = Display.GetValue(_ => _.Name, equipment),
                    Value = equipment.EquipmentId
                });
            }

            foreach (var varnish in dbContext.Varnishes)
            {
                viewModel.VarnishOptions.Add(new SelectOption {
                    Label = Display.GetValue(_ => _.Name, varnish),
                    Value = varnish.VarnishId
                });
            }

            foreach (var rims in dbContext.Rimses)
            {
                viewModel.RimsOptions.Add(new SelectOption {
                    Label = Display.GetValue(_ => _.Name, rims),
                    Value = rims.RimsId
                });
            }

            return(viewModel);
        }
示例#3
0
 public OrderService(KonfiguratorDbContext dbContext)
 {
     _dbContext = dbContext;
 }
 public static ConfigurationViewModel MapToViewModel(this Configuration configuration, KonfiguratorDbContext dbContext)
 {
     return(new ConfigurationViewModel()
     {
         EnginePower = configuration.EnginePower ?? 0,
         EquipmentValues = configuration.Equipments.Select(_ => _.EquipmentId).ToList(),
         Name = configuration.Name,
         RimsValue = configuration.Rims.RimsId,
         VarnishValue = configuration.Varnish.VarnishId,
     });
 }
 public static Configuration MapToBusinessObject(this ConfigurationViewModel configuration, KonfiguratorDbContext dbContext)
 {
     return(new Configuration {
         EnginePower = configuration.EnginePower,
         Equipments = configuration.EquipmentValues.Select(e => dbContext.Equipments.Single(_ => _.EquipmentId == e)).ToList(),
         Name = configuration.Name,
         Rims = configuration.RimsValue.HasValue ? dbContext.Rimses.Single(_ => _.RimsId == configuration.RimsValue) : null,
         Varnish = configuration.VarnishValue.HasValue ? dbContext.Varnishes.Single(_ => _.VarnishId == configuration.VarnishValue) : null
     });
 }
示例#6
0
 public ViewModelService(KonfiguratorDbContext dbContext)
 {
     _dbContext = dbContext;
 }