private void AddActivityFieldCommand_Execute()
        {
            var fields = UnitOfWork.ActivityFields.GetAll().Select(x => new ActivityFieldWrapper(x)).Except(Company.ActivityFilds);
            var field  = _selectService.SelectItem(fields);

            if (field != null && !Company.ActivityFilds.Contains(field))
            {
                Company.ActivityFilds.Add(field);
            }
        }
        public PaymentConditionViewModel(PaymentConditionSet paymentConditionSet, IUnityContainer container)
        {
            _unitOfWork             = container.Resolve <IUnitOfWork>();
            PaymentConditionWrapper = new PaymentConditionWrapper2(paymentConditionSet)
            {
                Part = 1.0 - paymentConditionSet.PaymentConditions.Sum(condition => condition.Part),
                PaymentConditionPoint = new PaymentConditionPointWrapper(_unitOfWork.Repository <PaymentConditionPoint>().GetAll().First())
            };

            OkCommand = new DelegateLogCommand(
                () =>
            {
                PaymentCondition paymentCondition = this.PaymentConditionWrapper.Model;

                //если условие новое
                if (_unitOfWork.Repository <PaymentCondition>()
                    .Find(condition => Equals(condition, paymentCondition))
                    .Any() == false)
                {
                    if (_unitOfWork.SaveEntity(paymentCondition).OperationCompletedSuccessfully)
                    {
                        this.PaymentConditionWrapper.AcceptChanges();
                        container.Resolve <IEventAggregator>().GetEvent <AfterSavePaymentConditionEvent>().Publish(paymentCondition);
                    }
                    else
                    {
                        return;
                    }
                }

                IsOk = true;
                CloseRequested?.Invoke(this, new DialogRequestCloseEventArgs(true));
            },
                () => PaymentConditionWrapper.IsValid && PaymentConditionWrapper.IsChanged);

            PaymentConditionWrapper.PropertyChanged += (sender, args) => OkCommand.RaiseCanExecuteChanged();

            SelectPaymentConditionPointCommand = new DelegateLogCommand(
                () =>
            {
                ISelectService selectService = container.Resolve <ISelectService>();
                PaymentConditionPoint point  = selectService.SelectItem(_unitOfWork.Repository <PaymentConditionPoint>().GetAll());
                if (point != null)
                {
                    this.PaymentConditionWrapper.PaymentConditionPoint = new PaymentConditionPointWrapper(point);
                }
            });

            ClearPaymentConditionPointCommand = new DelegateLogCommand(
                () =>
            {
                this.PaymentConditionWrapper.PaymentConditionPoint = null;
            });
        }