Пример #1
0
 public ComplaintPanelView(IComplaintsRepository complaintsRepository, IComplaintResultsRepository complaintResultsRepository)
 {
     this.complaintsRepository   = complaintsRepository ?? throw new ArgumentNullException(nameof(complaintsRepository));
     _complaintResultsRepository = complaintResultsRepository ?? throw new ArgumentNullException(nameof(complaintResultsRepository));
     Build();
     ConfigureWidget();
 }
        public ComplaintViewModel(
            IEntityUoWBuilder uowBuilder,
            IUnitOfWorkFactory uowFactory,
            ICommonServices commonServices,
            IUndeliveredOrdersJournalOpener undeliveryViewOpener,
            IEmployeeService employeeService,
            IEntityAutocompleteSelectorFactory counterpartySelectorFactory,
            IFileDialogService fileDialogService,
            ISubdivisionRepository subdivisionRepository,
            INomenclatureRepository nomenclatureRepository,
            IUserRepository userRepository,
            IOrderSelectorFactory orderSelectorFactory,
            IEmployeeJournalFactory driverJournalFactory,
            ICounterpartyJournalFactory counterpartyJournalFactory,
            IDeliveryPointJournalFactory deliveryPointJournalFactory,
            ISubdivisionJournalFactory subdivisionJournalFactory,
            IGtkTabsOpener gtkDialogsOpener,
            IUndeliveredOrdersJournalOpener undeliveredOrdersJournalOpener,
            ISalesPlanJournalFactory salesPlanJournalFactory,
            INomenclatureJournalFactory nomenclatureSelector,
            IUndeliveredOrdersRepository undeliveredOrdersRepository,
            IEmployeeSettings employeeSettings,
            IComplaintResultsRepository complaintResultsRepository) : base(uowBuilder, uowFactory, commonServices)
        {
            CounterpartySelectorFactory = counterpartySelectorFactory ?? throw new ArgumentNullException(nameof(counterpartySelectorFactory));
            FileDialogService           = fileDialogService ?? throw new ArgumentNullException(nameof(fileDialogService));
            SubdivisionRepository       = subdivisionRepository ?? throw new ArgumentNullException(nameof(subdivisionRepository));
            _undeliveryViewOpener       = undeliveryViewOpener ?? throw new ArgumentNullException(nameof(undeliveryViewOpener));
            EmployeeService             = employeeService ?? throw new ArgumentNullException(nameof(employeeService));
            NomenclatureRepository      = nomenclatureRepository ?? throw new ArgumentNullException(nameof(nomenclatureRepository));
            UserRepository              = userRepository ?? throw new ArgumentNullException(nameof(userRepository));
            _salesPlanJournalFactory    = salesPlanJournalFactory ?? throw new ArgumentNullException(nameof(salesPlanJournalFactory));
            _complaintResultsRepository = complaintResultsRepository ?? throw new ArgumentNullException(nameof(complaintResultsRepository));
            NomenclatureSelector        = nomenclatureSelector ?? throw new ArgumentNullException(nameof(nomenclatureSelector));
            UndeliveredOrdersRepository =
                undeliveredOrdersRepository ?? throw new ArgumentNullException(nameof(undeliveredOrdersRepository));
            _employeeSettings              = employeeSettings ?? throw new ArgumentNullException(nameof(employeeSettings));
            OrderSelectorFactory           = orderSelectorFactory ?? throw new ArgumentNullException(nameof(orderSelectorFactory));
            EmployeeJournalFactory         = driverJournalFactory ?? throw new ArgumentNullException(nameof(driverJournalFactory));
            _employeeSelectorFactory       = EmployeeJournalFactory.CreateEmployeeAutocompleteSelectorFactory();
            CounterpartyJournalFactory     = counterpartyJournalFactory ?? throw new ArgumentNullException(nameof(counterpartyJournalFactory));
            DeliveryPointJournalFactory    = deliveryPointJournalFactory ?? throw new ArgumentNullException(nameof(deliveryPointJournalFactory));
            SubdivisionJournalFactory      = subdivisionJournalFactory ?? throw new ArgumentNullException(nameof(subdivisionJournalFactory));
            GtkDialogsOpener               = gtkDialogsOpener ?? throw new ArgumentNullException(nameof(gtkDialogsOpener));
            UndeliveredOrdersJournalOpener = undeliveredOrdersJournalOpener ?? throw new ArgumentNullException(nameof(undeliveredOrdersJournalOpener));

            Entity.ObservableComplaintDiscussions.ElementChanged     += ObservableComplaintDiscussions_ElementChanged;
            Entity.ObservableComplaintDiscussions.ListContentChanged += ObservableComplaintDiscussions_ListContentChanged;
            Entity.ObservableFines.ListContentChanged += ObservableFines_ListContentChanged;

            if (uowBuilder.IsNewEntity)
            {
                AbortOpening("Невозможно создать новую рекламацию из текущего диалога, необходимо использовать диалоги создания");
            }

            if (CurrentEmployee == null)
            {
                AbortOpening("Невозможно открыть рекламацию так как к вашему пользователю не привязан сотрудник");
            }

            ConfigureEntityChangingRelations();

            CreateCommands();

            _complaintKinds = complaintKindSource = UoW.GetAll <ComplaintKind>().Where(k => !k.IsArchive).ToList();

            ComplaintObject = Entity.ComplaintKind?.ComplaintObject;

            TabName = $"Рекламация №{Entity.Id} от {Entity.CreationDate.ToShortDateString()}";

            _canAddGuiltyInComplaintsPermissionResult = CommonServices.CurrentPermissionService.ValidatePresetPermission("can_add_guilty_in_complaints");
            _canCloseComplaintsPermissionResult       = CommonServices.CurrentPermissionService.ValidatePresetPermission("can_close_complaints");

            if (Entity.ComplaintResultOfEmployees != null && Entity.ComplaintResultOfEmployees.IsArchive)
            {
                ComplaintResultsOfEmployees =
                    _complaintResultsRepository.GetActiveResultsOfEmployeesWithSelectedResult(UoW, Entity.ComplaintResultOfEmployees.Id);
            }
            else
            {
                ComplaintResultsOfEmployees = _complaintResultsRepository.GetActiveResultsOfEmployees(UoW);
            }
        }