public FixedPriceItemViewModel(NomenclatureFixedPrice fixedPrice, IFixedPricesModel fixedPriceModel) { NomenclatureFixedPrice = fixedPrice ?? throw new ArgumentNullException(nameof(fixedPrice)); this.fixedPriceModel = fixedPriceModel ?? throw new ArgumentNullException(nameof(fixedPriceModel)); fixedPrice.PropertyChanged += FixedPriceOnPropertyChanged; }
public FixedPricesViewModel(IUnitOfWork uow, IFixedPricesModel fixedPricesModel, INomenclatureSelectorFactory nomenclatureSelectorFactory, ITdiTab parentTab) { UoW = uow ?? throw new ArgumentNullException(nameof(uow)); this.fixedPricesModel = fixedPricesModel ?? throw new ArgumentNullException(nameof(fixedPricesModel)); this.nomenclatureSelectorFactory = nomenclatureSelectorFactory ?? throw new ArgumentNullException(nameof(nomenclatureSelectorFactory)); this.parentTab = parentTab ?? throw new ArgumentNullException(nameof(parentTab)); fixedPricesModel.FixedPricesUpdated += (sender, args) => UpdateFixedPrices(); UpdateFixedPrices(); }
public DeliveryPointViewModel( IUserRepository userRepository, IGtkTabsOpener gtkTabsOpener, IPhoneRepository phoneRepository, IContactsParameters contactsParameters, ICitiesDataLoader citiesDataLoader, IStreetsDataLoader streetsDataLoader, IHousesDataLoader housesDataLoader, INomenclatureJournalFactory nomenclatureSelectorFactory, NomenclatureFixedPriceController nomenclatureFixedPriceController, IDeliveryPointRepository deliveryPointRepository, IDeliveryScheduleSelectorFactory deliveryScheduleSelectorFactory, IEntityUoWBuilder uowBuilder, IUnitOfWorkFactory unitOfWorkFactory, ICommonServices commonServices, IRoboAtsCounterpartyJournalFactory roboAtsCounterpartyJournalFactory, Domain.Client.Counterparty client = null) : base(uowBuilder, unitOfWorkFactory, commonServices) { if (client != null && uowBuilder.IsNewEntity) { Entity.Counterparty = client; } else if (client == null && uowBuilder.IsNewEntity) { throw new ArgumentNullException(nameof(client), "Нельзя создать точку доставки без указания клиента"); } if (phoneRepository == null) { throw new ArgumentNullException(nameof(phoneRepository)); } if (contactsParameters == null) { throw new ArgumentNullException(nameof(contactsParameters)); } if (nomenclatureFixedPriceController == null) { throw new ArgumentNullException(nameof(nomenclatureFixedPriceController)); } _deliveryPointRepository = deliveryPointRepository ?? throw new ArgumentNullException(nameof(deliveryPointRepository)); _gtkTabsOpener = gtkTabsOpener ?? throw new ArgumentNullException(nameof(gtkTabsOpener)); _userRepository = userRepository ?? throw new ArgumentNullException(nameof(userRepository)); NomenclatureSelectorFactory = nomenclatureSelectorFactory ?? throw new ArgumentNullException(nameof(nomenclatureSelectorFactory)); _fixedPricesModel = new DeliveryPointFixedPricesModel(UoW, Entity, nomenclatureFixedPriceController); PhonesViewModel = new PhonesViewModel(phoneRepository, UoW, contactsParameters, roboAtsCounterpartyJournalFactory, CommonServices) { PhonesList = Entity.ObservablePhones, DeliveryPoint = Entity, ReadOnly = !CanEdit }; CitiesDataLoader = citiesDataLoader ?? throw new ArgumentNullException(nameof(citiesDataLoader)); StreetsDataLoader = streetsDataLoader ?? throw new ArgumentNullException(nameof(streetsDataLoader)); HousesDataLoader = housesDataLoader ?? throw new ArgumentNullException(nameof(housesDataLoader)); CanArchiveDeliveryPoint = commonServices.CurrentPermissionService.ValidatePresetPermission("can_arc_counterparty_and_deliverypoint"); CanSetFreeDelivery = commonServices.CurrentPermissionService.ValidatePresetPermission("can_set_free_delivery"); CanEditOrderLimits = commonServices.CurrentPermissionService.ValidatePresetPermission("user_can_edit_orders_limits"); CanEditNomenclatureFixedPrice = commonServices.CurrentPermissionService.ValidatePresetPermission("can_edit_delivery_point_fixed_prices"); DeliveryPointCategories = deliveryPointRepository?.GetActiveDeliveryPointCategories(UoW) ?? throw new ArgumentNullException(nameof(deliveryPointRepository)); DeliveryScheduleSelectorFactory = deliveryScheduleSelectorFactory?.CreateDeliveryScheduleAutocompleteSelectorFactory() ?? throw new ArgumentNullException(nameof(deliveryScheduleSelectorFactory)); _roboAtsCounterpartyJournalFactory = roboAtsCounterpartyJournalFactory ?? throw new ArgumentNullException(nameof(roboAtsCounterpartyJournalFactory)); Entity.PropertyChanged += (sender, e) => { switch (e.PropertyName) { // от этого события зависит панель цен доставки, которые в свою очередь зависят от района и, возможно, фиксов case nameof(Entity.District): CurrentObjectChanged?.Invoke(this, new CurrentObjectChangedArgs(Entity)); break; } }; }