public static DriverDistrictPrioritySet CopyPrioritySetWithActiveDistricts(DriverDistrictPrioritySet districtPrioritySet, out IList <DriverDistrictPriority> notCopiedPriorities)
        {
            var copy = (DriverDistrictPrioritySet)districtPrioritySet.Clone();

            notCopiedPriorities = new List <DriverDistrictPriority>();

            for (int i = 0; i < copy.DriverDistrictPriorities.Count; i++)
            {
                if (copy.DriverDistrictPriorities[i].District.IsActive)
                {
                    continue;
                }
                var activeDistrict = District.GetDistrictFromActiveDistrictsSetOrNull(copy.DriverDistrictPriorities[i].District);
                if (activeDistrict != null)
                {
                    copy.DriverDistrictPriorities[i].District = activeDistrict;
                }
                else
                {
                    notCopiedPriorities.Add(districtPrioritySet.DriverDistrictPriorities[i]);
                    copy.DriverDistrictPriorities.RemoveAt(i);
                    i--;
                }
            }
            copy.CheckAndFixDistrictsPriorities();
            return(copy);
        }
        public DriverDistrictPrioritySetViewModel(
            DriverDistrictPrioritySet entity,
            IUnitOfWork uow,
            IUnitOfWorkFactory unitOfWorkFactory,
            ICommonServices commonServices,
            IDefaultDeliveryDayScheduleSettings defaultDeliveryDayScheduleSettings,
            IEmployeeRepository employeeRepository,
            INavigationManager navigation = null)
            : base(commonServices.InteractiveService, navigation)
        {
            if (defaultDeliveryDayScheduleSettings == null)
            {
                throw new ArgumentNullException(nameof(defaultDeliveryDayScheduleSettings));
            }
            this.uow = uow ?? throw new ArgumentNullException(nameof(uow));
            this.unitOfWorkFactory  = unitOfWorkFactory ?? throw new ArgumentNullException(nameof(unitOfWorkFactory));
            this.employeeRepository = employeeRepository ?? throw new ArgumentNullException(nameof(employeeRepository));
            this.commonServices     = commonServices;

            Entity           = entity ?? new DriverDistrictPrioritySet();
            permissionResult = commonServices.CurrentPermissionService.ValidateEntityPermission(typeof(DriverDistrictPrioritySet));
            OnPropertyChanged(nameof(CanEdit));

            FillObservableDriverWorkSchedules();
            UpdateTabName();

            Entity.PropertyChanged += (sender, args) => {
                switch (args.PropertyName)
                {
                case nameof(Entity.Driver):
                    UpdateTabName();
                    break;

                case nameof(Entity.Id):
                    OnPropertyChanged(nameof(Id));
                    OnPropertyChanged(nameof(IsInfoVisible));
                    break;

                case nameof(Entity.Author):
                    OnPropertyChanged(nameof(Author));
                    break;

                case nameof(Entity.DateActivated):
                    OnPropertyChanged(nameof(DateActivated));
                    break;

                case nameof(Entity.DateDeactivated):
                    OnPropertyChanged(nameof(DateDeactivated));
                    break;
                }
            };
        }
Ejemplo n.º 3
0
        private void OpenDistrictPrioritySetCreateWindow()
        {
            var newDistrictPrioritySet = new DriverDistrictPrioritySet {
                Driver = Entity,
                IsCreatedAutomatically = false
            };

            var driverDistrictPrioritySetViewModel = new DriverDistrictPrioritySetViewModel(
                newDistrictPrioritySet,
                UoW,
                UnitOfWorkFactory.GetDefaultFactory,
                ServicesConfig.CommonServices,
                new BaseParametersProvider(),
                EmployeeSingletonRepository.GetInstance()
                );

            driverDistrictPrioritySetViewModel.EntityAccepted += (o, eventArgs) => {
                Entity.AddActiveDriverDistrictPrioritySet(newDistrictPrioritySet);
            };

            TabParent.AddSlaveTab(this, driverDistrictPrioritySetViewModel);
        }
 public DriverDistrictPrioritySetAcceptedEventArgs(DriverDistrictPrioritySet driverDistrictPrioritySet)
 {
     AcceptedEntity = driverDistrictPrioritySet;
 }