public static LomoConfig Convert(LomoConfigViewModel lomoConfigViewModel)
        {
            var converted = new LomoConfig
            {
                Id = lomoConfigViewModel.Id,
                BoxCount = lomoConfigViewModel.BoxCount.DataValue.Value,
                Customer = Convert(lomoConfigViewModel.SelectedCustomer.DataValue),
                Description = lomoConfigViewModel.Description.DataValue,
                ImagePath = lomoConfigViewModel.ImagePath.DataValue,
                Name = lomoConfigViewModel.Name.DataValue
            };

            return converted;
        }
        public static LomoConfigViewModel Convert(LomoConfig lomoConfig, ICustomerRepository customerRepository, IOpenFileService openFileService)
        {
            var viewModel = new LomoConfigViewModel(lomoConfig.Name, openFileService, customerRepository)
            {
                Id = lomoConfig.Id,
                BoxCount = { DataValue = lomoConfig.BoxCount },
                SelectedCustomer = { DataValue = lomoConfig.Customer != null ? Convert(lomoConfig.Customer) : null },
                Description = { DataValue = lomoConfig.Description },
                ImagePath = { DataValue = lomoConfig.ImagePath },
                Fields = new ObservableCollection<FieldViewModel>(lomoConfig.Fields.Select(Convert)),
            };

            return viewModel;
        }
 private int SaveNew(LomoConfigViewModel lomoConfigViewModel)
 {
     var lomoConfig = ViewModelToModelConverter.Convert(lomoConfigViewModel);
     return lomoConfigService.Add(lomoConfig);
 }
 private void Add()
 {
     var lomoConfigViewModel = new LomoConfigViewModel(GenerateNewName(), openFileService, customerRepository)
     {
         Fields = new ObservableCollection<FieldViewModel>(defaultFieldsRepository.GetAll().Select(ModelToViewModelConverter.Convert))
     };
     Hook(lomoConfigViewModel);
     Configs.Add(lomoConfigViewModel);
     SelectedConfig = lomoConfigViewModel;
     UpdateState();
 }
 private void Update(LomoConfigViewModel lomoConfigViewModel)
 {
     var lomoConfig = ViewModelToModelConverter.Convert(lomoConfigViewModel);
     lomoConfigService.Update(lomoConfig);
 }