Пример #1
0
 public void AddValidations(params IValidationRule <T>[] validations)
 {
     foreach (var validation in validations)
     {
         Validations.Add(validation);
     }
 }
Пример #2
0
        public NomenclatureViewModel(
            BaseParameters baseParameters,
            IEntityUoWBuilder uowBuilder,
            IUnitOfWorkFactory unitOfWorkFactory,
            INavigationManager navigation,
            ILifetimeScope autofacScope,
            IValidator validator = null) : base(uowBuilder, unitOfWorkFactory, navigation, validator)
        {
            var entryBuilder =
                new CommonEEVMBuilderFactory <Nomenclature>(this, Entity, UoW, navigation, autofacScope);

            ItemTypeEntryViewModel = entryBuilder.ForProperty(x => x.Type)
                                     .MakeByType()
                                     .Finish();
            Validations.Clear();
            Validations.Add(
                new ValidationRequest(Entity,
                                      new ValidationContext(Entity,
                                                            new Dictionary <object, object> {
                { nameof(BaseParameters), baseParameters },
                { nameof(IUnitOfWork), UoW }
            })));

            Entity.PropertyChanged += Entity_PropertyChanged;
        }
Пример #3
0
 public SizeTypeViewModel(
     IEntityUoWBuilder uowBuilder,
     IUnitOfWorkFactory unitOfWorkFactory,
     INavigationManager navigation,
     SizeService sizeService,
     IValidator validator = null) : base(uowBuilder, unitOfWorkFactory, navigation, validator)
 {
     this.sizeService = sizeService;
     Validations.Clear();
     Validations.Add(new ValidationRequest(Entity,
                                           new ValidationContext(Entity, new Dictionary <object, object> {
         { nameof(IUnitOfWork), UoW }
     })));
     if (UoW.IsNew)
     {
         IsNew = true;
         Sizes = new GenericObservableList <Size>();
     }
     else
     {
         Sizes = new GenericObservableList <Size>(sizeService.GetSize(UoW, Entity).ToList());
         if (Entity.Id <= SizeService.MaxStandartSizeTypeId)
         {
             IsStandartType = true;
         }
     }
 }
Пример #4
0
 public SizeViewModel(
     IEntityUoWBuilder uowBuilder,
     IUnitOfWorkFactory unitOfWorkFactory,
     INavigationManager navigation,
     SizeService sizeService,
     SizeType sizeType    = null,
     IValidator validator = null) : base(uowBuilder, unitOfWorkFactory, navigation, validator)
 {
     SizeService = sizeService;
     Validations.Clear();
     Validations.Add(new ValidationRequest(Entity,
                                           new ValidationContext(Entity, new Dictionary <object, object> {
         { nameof(IUnitOfWork), UoW }
     })));
     if (UoW.IsNew)
     {
         Entity.SizeType = sizeType;
         IsNew           = true;
     }
     else
     {
         if (Entity.Id <= SizeService.MaxStandartSizeId)
         {
             IsStandart = true;
         }
     }
 }
Пример #5
0
        /// <summary>
        /// Configura este result com as informações de outro result (message, messageCode e validations).
        /// </summary>
        /// <param name="result"></param>
        public virtual Result SetFromAnother(Result result)
        {
            if (result == null)
            {
                return(this);
            }

            Message    = result.Message;
            ResultCode = result.ResultCode;

            if (result.Validations != null && result.Validations.Any())
            {
                if (Validations == null)
                {
                    Validations = new List <ResultValidation>();
                }

                foreach (ResultValidation validation in result.Validations)
                {
                    Validations.Add(validation);
                }
            }
            else
            {
                Validations = new List <ResultValidation>();
            }

            return(this);
        }
Пример #6
0
 public void Validate()
 {
     if (Value > LuckyList.Last())
     {
         Validations.Add("Invalid Lucky List or Number");
     }
 }
Пример #7
0
 public ValidatableModel(Action propertyChangedCallback = null, params IValidationRule <T>[] validations)
 {
     this.propertyChangedCallback = propertyChangedCallback;
     foreach (var val in validations)
     {
         Validations.Add(val);
     }
 }
        internal AbstractPageRequest(Session request, AbstractStep myStep, Page page)
            : base(request, page)
        {
            Validations.Add(myStep.CreateDefaultValidationFromRequest(request));
            FollowRedirects   = new List <AbstractFollowRedirect>();
            SecondaryRequests = new List <Session>();

            MyStep = myStep;
        }
        /// <summary>
        /// Adds the validation received as parameter in the validations list.
        /// </summary>
        /// <param name="val">Validation to add</param>
        public void AddValidation(AbstractValidation val)
        {
            if (Validations.Count == 1 && Validations[0] is DefaultValidation)
            {
                Validations.RemoveAt(0);
            }

            Validations.Add(val);
        }
Пример #10
0
        public TestViewModel()
        {
            Validations.Add(this,
                            x => x._myProperty,
                            x => x != 25,
                            x => Validation.Error("Hello world"));

            Validations.Add(this,
                            x => x._myProperty,
                            Test,
                            x => Validation.Error("another validation"));
        }
        public CompletionViewModel(IEntityUoWBuilder uowBuilder,
                                   IUnitOfWorkFactory unitOfWorkFactory,
                                   INavigationManager navigation,
                                   IUserService userService,
                                   StockRepository stockRepository,
                                   FeaturesService featuresService,
                                   ILifetimeScope autofacScope,
                                   BaseParameters baseParameters,
                                   IInteractiveQuestion interactive,
                                   SizeService sizeService,
                                   IValidator validator = null) : base(uowBuilder, unitOfWorkFactory, navigation, validator)
        {
            var entryBuilder = new CommonEEVMBuilderFactory <Completion>(this, Entity, UoW, navigation, autofacScope);

            this.interactive     = interactive;
            this.featuresService = featuresService;
            SizeService          = sizeService;

            if (UoW.IsNew)
            {
                Entity.CreatedbyUser = userService.GetCurrentUser(UoW);
            }

            if (Entity.SourceWarehouse == null)
            {
                Entity.SourceWarehouse = stockRepository.GetDefaultWarehouse
                                             (UoW, featuresService, autofacScope.Resolve <IUserService>().CurrentUserId);
            }

            WarehouseExpenseEntryViewModel = entryBuilder.ForProperty(x => x.SourceWarehouse)
                                             .UseViewModelJournalAndAutocompleter <WarehouseJournalViewModel>()
                                             .UseViewModelDialog <WarehouseViewModel>()
                                             .Finish();

            if (Entity.ResultWarehouse == null)
            {
                Entity.ResultWarehouse = stockRepository.GetDefaultWarehouse
                                             (UoW, featuresService, autofacScope.Resolve <IUserService>().CurrentUserId);
            }

            WarehouseReceiptEntryViewModel = entryBuilder.ForProperty(x => x.ResultWarehouse)
                                             .UseViewModelJournalAndAutocompleter <WarehouseJournalViewModel>()
                                             .UseViewModelDialog <WarehouseViewModel>()
                                             .Finish();

            Validations.Clear();
            Validations.Add(new ValidationRequest(Entity,
                                                  new ValidationContext(Entity, new Dictionary <object, object> {
                { nameof(BaseParameters), baseParameters }, { nameof(IUnitOfWork), UoW }
            })));
            Entity.PropertyChanged += Entity_PropertyChanged;
            lastWarehouse           = Entity.SourceWarehouse;
        }
Пример #12
0
        public MainWindowViewModel()
        {
            Validations.Add(this, x => x._test, s => s == "nobody", x => Validation.Error("name should not be nobody"));
            Validations.Add(this, x => x._test, s => s == "nobody", x => Validation.Error("Name should not be nobody"));
            Validations.Add(this, x => x._test, s => s == "Tim", x => Validation.Error("Nööö"));
            Validations.Add(this, x => x._test, s => s.Length < 4, x => Validation.Error("Muss länger als 3 sein"));
            Validations.Add(this, x => x._numberTest, i => i < 25 || i > 50, x => Validation.Error("NumberTest has to be between 25 and 50"));

            InitializeCommand = new AsyncCommand(async _ =>
            {
                NumberTest = 25;
                await Task.CompletedTask;
            });
        }
        public EntityDialogViewModelBase(IEntityUoWBuilder uowBuilder, IUnitOfWorkFactory unitOfWorkFactory, INavigationManager navigation, IValidator validator = null) : base(unitOfWorkFactory, navigation, validator)
        {
            if (uowBuilder == null)
            {
                throw new ArgumentNullException(nameof(uowBuilder));
            }
            UoWGeneric = uowBuilder.CreateUoW <TEntity>(unitOfWorkFactory);
            base.Title = GetDialogNameByEntity();
            if (Entity is INotifyPropertyChanged propertyChanged)
            {
                propertyChanged.PropertyChanged += Entity_PropertyChanged;
            }

            Validations.Add(new ValidationRequest(Entity));
        }
Пример #14
0
 private void ChecaElemento(Elemento elemento)
 {
     if (string.IsNullOrEmpty(elemento.Nome))
     {
         Validations.Add(EnumValidateModel.CASO_EMPTY_COMANDOLIST);
     }
     if (string.IsNullOrEmpty(elemento.CodigoUi))
     {
         throw new Exception();
     }
     else if (string.IsNullOrEmpty(elemento.TipoControle))
     {
         throw new Exception();
     }
 }
Пример #15
0
 private void ChecaCaso(Caso caso)
 {
     if (string.IsNullOrEmpty(caso.Nome))
     {
         Validations.Add(EnumValidateModel.CASO_EMPTY_NOME);
     }
     else if (caso.ComandoLista == null || caso.ComandoLista.Count == 0)
     {
         Validations.Add(EnumValidateModel.CASO_EMPTY_COMANDOLIST);
     }
     else if (caso.Order <= 0)
     {
         Validations.Add(EnumValidateModel.CASO_EMPTY_ORDER);
     }
 }
Пример #16
0
        public MvcHtmlString HirjiCalendarGroup(
            bool isRequired,
            int size,
            string alternateLabel,
            string placeHolder,
            object attrs,
            object inputAttr,
            CalendarTypes type,
            DateRange range)
        {
            GroupModel.Label = alternateLabel == null?GetLabel(typeof(T).Name, MemberName) : alternateLabel;

            GroupModel.Size       = size;
            GroupModel.Attributes = ToAttributeString(attrs);

            InputModel.PlaceHolder     = placeHolder != null ? placeHolder : GroupModel.Label;
            InputModel.AttributeObject = inputAttr;

            Validations = Helper.VCollection();

            if (type == CalendarTypes.Custom)
            {
                Validations.Add(new DateValidator(NgOptions.DateValidationPattern, range));
            }
            else
            {
                Validations.Add(new DateValidator(NgOptions.DateValidationPattern, type));
            }

            if (InputModel.AttributeObject == null && range != null)
            {
                InputModel.AttributeObject = new { data_date_start_date = range.StartDate, data_date_end_date = range.EndDate }
            }
            ;

            if (isRequired)
            {
                Validations.AddRequired();

                GroupModel.IsRequired = true;
            }

            Validations.SetMember(MemberName, typeof(T).Name);
            GroupModel.ValidationMessages = Validations.GetMessages();
            GroupModel.InputControl       = GetInputControl(ComponentNames.HijriCalendarTextBox);

            return(GetView("Components/ControlGroup", GroupModel));
        }
        public CollectiveExpenseViewModel(IEntityUoWBuilder uowBuilder,
                                          IUnitOfWorkFactory unitOfWorkFactory,
                                          INavigationManager navigation,
                                          ILifetimeScope autofacScope,
                                          IValidator validator,
                                          IUserService userService,
                                          UserRepository userRepository,
                                          IInteractiveQuestion interactive,
                                          StockRepository stockRepository,
                                          CommonMessages commonMessages,
                                          FeaturesService featuresService,
                                          BaseParameters baseParameters
                                          ) : base(uowBuilder, unitOfWorkFactory, navigation, validator)
        {
            this.autofacScope    = autofacScope ?? throw new ArgumentNullException(nameof(autofacScope));
            this.userRepository  = userRepository ?? throw new ArgumentNullException(nameof(userRepository));
            this.interactive     = interactive;
            this.commonMessages  = commonMessages ?? throw new ArgumentNullException(nameof(commonMessages));
            this.featuresService = featuresService ?? throw new ArgumentNullException(nameof(featuresService));
            this.baseParameters  = baseParameters ?? throw new ArgumentNullException(nameof(baseParameters));
            var entryBuilder = new CommonEEVMBuilderFactory <CollectiveExpense>(this, Entity, UoW, navigation, autofacScope);

            if (UoW.IsNew)
            {
                Entity.CreatedbyUser = userService.GetCurrentUser(UoW);
            }

            if (Entity.Warehouse == null)
            {
                Entity.Warehouse = stockRepository.GetDefaultWarehouse(UoW, featuresService, autofacScope.Resolve <IUserService>().CurrentUserId);
            }

            WarehouseEntryViewModel = entryBuilder.ForProperty(x => x.Warehouse).MakeByType().Finish();

            var parameter = new TypedParameter(typeof(CollectiveExpenseViewModel), this);

            CollectiveExpenseItemsViewModel = this.autofacScope.Resolve <CollectiveExpenseItemsViewModel>(parameter);
            //Переопределяем параметры валидации
            Validations.Clear();
            Validations.Add(new ValidationRequest(Entity, new ValidationContext(Entity, new Dictionary <object, object> {
                { nameof(BaseParameters), baseParameters }
            })));
        }
        public WarehouseTransferViewModel(
            IEntityUoWBuilder uowBuilder,
            IUnitOfWorkFactory unitOfWorkFactory,
            INavigationManager navigationManager,
            ILifetimeScope autofacScope,
            IValidator validator,
            IUserService userService,
            BaseParameters baseParameters,
            IInteractiveQuestion interactive) : base(uowBuilder, unitOfWorkFactory, navigationManager, validator)
        {
            this.AutofacScope = autofacScope ?? throw new ArgumentNullException(nameof(autofacScope));
            this.interactive  = interactive ?? throw new ArgumentNullException(nameof(interactive));
            if (UoW.IsNew)
            {
                Entity.CreatedbyUser = userService.GetCurrentUser(UoW);
            }

            var entryBuilder = new CommonEEVMBuilderFactory <Transfer>(this, Entity, UoW, navigationManager)
            {
                AutofacScope = AutofacScope
            };

            WarehouseFromEntryViewModel = entryBuilder.ForProperty(x => x.WarehouseFrom)
                                          .UseViewModelJournalAndAutocompleter <WarehouseJournalViewModel>()
                                          .UseViewModelDialog <WarehouseViewModel>()
                                          .Finish();
            WarehouseToEntryViewModel = entryBuilder.ForProperty(x => x.WarehouseTo)
                                        .UseViewModelJournalAndAutocompleter <WarehouseJournalViewModel>()
                                        .UseViewModelDialog <WarehouseViewModel>()
                                        .Finish();
            LoadActualAmountFromStock();
            Entity.PropertyChanged += Entity_PropertyChanged;
            lastWarehouse           = Entity.WarehouseFrom;

            //Переопределяем параметры валидации
            Validations.Clear();
            Validations.Add(new ValidationRequest(Entity, new ValidationContext(Entity,
                                                                                new Dictionary <object, object> {
                { nameof(BaseParameters), baseParameters }
            })));
        }
Пример #19
0
        private void Checagem(Suite SuiteConceito)
        {
            if (SuiteConceito.CasoLista == null && SuiteConceito.CasoLista.Count == 0)
            {
                Validations.Add(EnumValidateModel.SUITE_ENPTY_CASOLISTA);
            }
            if (string.IsNullOrEmpty(SuiteConceito.Nome))
            {
                Validations.Add(EnumValidateModel.SUITE_EMPTY_NOME);
            }

            foreach (var caso in SuiteConceito.CasoLista)
            {
                ChecaCaso(caso);
                foreach (var comando in caso.ComandoLista)
                {
                    ChecaComando(comando);
                    ChecaElemento(comando.Elemento);
                }
            }
        }
Пример #20
0
        /// <summary>
        /// Adiciona uma validação e seta o result code para BusinessError caso o status atual seja OK (válido).
        /// </summary>
        /// <param name="attribute"></param>
        /// <param name="message"></param>
        public virtual Result AddValidation(string attribute, string message)
        {
            if (string.IsNullOrWhiteSpace(attribute))
            {
                throw new ArgumentException($"The parameter {nameof(attribute)} is required to add validation to result.");
            }

            if (string.IsNullOrWhiteSpace(message))
            {
                throw new ArgumentException($"The parameter {nameof(message)} is required to add validation to result.");
            }

            Validations.Add(new ResultValidation {
                Attribute = attribute, Message = message
            });

            if (ResultCode == ResultCode.Ok)
            {
                Set(ResultCode.BusinessError, Constant.Validations);
            }

            return(this);
        }
Пример #21
0
        public EntityDialogViewModelBase(IEntityUoWBuilder uowBuilder, IUnitOfWorkFactory unitOfWorkFactory, INavigationManager navigation, IValidator validator = null) : base(unitOfWorkFactory, navigation, validator)
        {
            if (uowBuilder == null)
            {
                throw new ArgumentNullException(nameof(uowBuilder));
            }

            string actionTitle = null;

            if (typeof(TEntity).GetSubjectNames()?.Genitive != null)
            {
                actionTitle = $"Редактирование {typeof(TEntity).GetSubjectNames().Genitive}";
            }

            UoWGeneric = uowBuilder.CreateUoW <TEntity>(unitOfWorkFactory, actionTitle);
            base.Title = GetDialogNameByEntity();
            if (Entity is INotifyPropertyChanged propertyChanged)
            {
                propertyChanged.PropertyChanged += Entity_PropertyChanged;
            }

            Validations.Add(new ValidationRequest(Entity));
        }
 /// <summary>
 ///     Adds new validation rule.
 /// </summary>
 /// <param name="rule">Validation rule.</param>
 /// <returns>ValidatableObject.</returns>
 public ValidatableObject <T> AddRule(IValidationRule <T> rule)
 {
     Validations.Add(rule);
     return(this);
 }
Пример #23
0
        public EmployeeViewModel(
            IEntityUoWBuilder uowBuilder,
            IUnitOfWorkFactory unitOfWorkFactory,
            INavigationManager navigation,
            IValidator validator,
            IUserService userService,
            ILifetimeScope autofacScope,
            PersonNames personNames,
            IInteractiveService interactive,
            FeaturesService featuresService,
            EmployeeRepository employeeRepository,
            NormRepository normRepository,
            LkUserManagerService lkUserManagerService,
            BaseParameters baseParameters,
            SizeService sizeService,
            CommonMessages messages) : base(uowBuilder, unitOfWorkFactory, navigation, validator)
        {
            AutofacScope              = autofacScope ?? throw new ArgumentNullException(nameof(autofacScope));
            this.personNames          = personNames ?? throw new ArgumentNullException(nameof(personNames));
            this.interactive          = interactive ?? throw new ArgumentNullException(nameof(interactive));
            this.featuresService      = featuresService ?? throw new ArgumentNullException(nameof(featuresService));
            this.employeeRepository   = employeeRepository ?? throw new ArgumentNullException(nameof(employeeRepository));
            NormRepository            = normRepository ?? throw new ArgumentNullException(nameof(normRepository));
            this.lkUserManagerService = lkUserManagerService ?? throw new ArgumentNullException(nameof(lkUserManagerService));
            this.baseParameters       = baseParameters ?? throw new ArgumentNullException(nameof(baseParameters));
            this.messages             = messages ?? throw new ArgumentNullException(nameof(messages));
            var builder = new CommonEEVMBuilderFactory <EmployeeCard>(this, Entity, UoW, NavigationManager, AutofacScope);

            SizeService = sizeService;

            EntryLeaderViewModel = builder.ForProperty(x => x.Leader)
                                   .UseViewModelJournalAndAutocompleter <LeadersJournalViewModel>()
                                   .UseViewModelDialog <LeadersViewModel>()
                                   .Finish();

            EntrySubdivisionViewModel = builder.ForProperty(x => x.Subdivision)
                                        .UseViewModelJournalAndAutocompleter <SubdivisionJournalViewModel>()
                                        .UseViewModelDialog <SubdivisionViewModel>()
                                        .Finish();

            EntryDepartmentViewModel = builder.ForProperty(x => x.Department)
                                       .UseViewModelDialog <DepartmentViewModel>()
                                       .Finish();

            EntryDepartmentViewModel.EntitySelector = new DepartmentJournalViewModelSelector(
                this, NavigationManager, EntrySubdivisionViewModel);

            EntryPostViewModel = builder.ForProperty(x => x.Post)
                                 .UseViewModelJournalAndAutocompleter <PostJournalViewModel>()
                                 .UseViewModelDialog <PostViewModel>()
                                 .Finish();

            Entity.PropertyChanged += Entity_PropertyChanged;
            Entity.PropertyChanged += PostChangedCheck;

            if (UoW.IsNew)
            {
                Entity.CreatedbyUser = userService.GetCurrentUser(UoW);
                logger.Info("Создание карточки для нового сотрудника");
            }
            else
            {
                AutoCardNumber = String.IsNullOrWhiteSpace(Entity.CardNumber);
            }

            lastSubdivision = Entity.Subdivision;
            lastPost        = Entity.Post;

            //Создаем вкладки
            var parameter = new TypedParameter(typeof(EmployeeViewModel), this);

            NormsViewModel       = AutofacScope.Resolve <EmployeeNormsViewModel>(parameter);
            WearItemsViewModel   = AutofacScope.Resolve <EmployeeWearItemsViewModel>(parameter);
            ListedItemsViewModel = AutofacScope.Resolve <EmployeeListedItemsViewModel>(parameter);
            MovementsViewModel   = AutofacScope.Resolve <EmployeeMovementsViewModel>(parameter);
            VacationsViewModel   = AutofacScope.Resolve <EmployeeVacationsViewModel>(parameter);
            //Панели
            EmployeePhotoViewModel = AutofacScope.Resolve <EmployeePhotoViewModel>(parameter);

            VisiblePhoto = Entity.Photo != null;
            lkLastPhone  = Entity.PhoneNumber;
            LkPassword   = Entity.LkRegistered ? unknownPassword : String.Empty;

            Validations.Add(new ValidationRequest(this));
        }
        public ExpenseObjectViewModel(IEntityUoWBuilder uowBuilder,
                                      IUnitOfWorkFactory unitOfWorkFactory,
                                      INavigationManager navigation,
                                      ILifetimeScope autofacScope,
                                      IValidator validator,
                                      IUserService userService,
                                      IInteractiveQuestion interactive,
                                      StockRepository stockRepository,
                                      FeaturesService featutesService,
                                      BaseParameters baseParameters,
                                      Subdivision subdivision = null
                                      )
            : base(uowBuilder, unitOfWorkFactory, navigation, validator)
        {
            Entity.Date          = DateTime.Today;
            this.interactive     = interactive;
            this.stockRepository = stockRepository ?? throw new ArgumentNullException(nameof(stockRepository));
            this.baseParameters  = baseParameters ?? throw new ArgumentNullException(nameof(baseParameters));
            if (subdivision != null)
            {
                Entity.Subdivision = subdivision;
                Entity.Warehouse   = subdivision.Warehouse;
            }

            if (UoW.IsNew)
            {
                Entity.Operation     = ExpenseOperations.Object;
                Entity.CreatedbyUser = userService.GetCurrentUser(UoW);
            }
            if (Entity.Operation != ExpenseOperations.Object)
            {
                throw new InvalidOperationException("Диалог предназначен только для операций выдачи на подразделение.");
            }

            if (Entity.Warehouse == null)
            {
                Entity.Warehouse = stockRepository.GetDefaultWarehouse(UoW, featutesService, autofacScope.Resolve <IUserService>().CurrentUserId);
            }

            this.autofacScope = autofacScope ?? throw new ArgumentNullException(nameof(autofacScope));
            var entryBuilder = new CommonEEVMBuilderFactory <Expense>(this, Entity, UoW, navigation, autofacScope);

            WarehouseExpenceViewModel = entryBuilder.ForProperty(x => x.Warehouse)
                                        .UseViewModelJournalAndAutocompleter <WarehouseJournalViewModel>()
                                        .UseViewModelDialog <WarehouseViewModel>()
                                        .Finish();

            SubdivisionViewModel = entryBuilder.ForProperty(x => x.Subdivision)
                                   .UseViewModelJournalAndAutocompleter <SubdivisionJournalViewModel>()
                                   .UseViewModelDialog <SubdivisionViewModel>()
                                   .Finish();

            var parameter = new TypedParameter(typeof(ExpenseObjectViewModel), this);

            DocItemsObjectViewModel = this.autofacScope.Resolve <ExpenseDocItemsObjectViewModel>(parameter);

            //Переопределяем параметры валидации
            Validations.Clear();
            Validations.Add(new ValidationRequest(Entity, new ValidationContext(Entity, new Dictionary <object, object> {
                { nameof(BaseParameters), baseParameters }
            })));
        }
Пример #25
0
 public InvalidParameterException(string validation)
     : base(Messages.InvalidParameterException)
 {
     Code = "00001";
     Validations.Add(validation);
 }
Пример #26
0
        public ExpenseEmployeeViewModel(IEntityUoWBuilder uowBuilder,
                                        IUnitOfWorkFactory unitOfWorkFactory,
                                        INavigationManager navigation,
                                        ILifetimeScope autofacScope,
                                        IValidator validator,
                                        IUserService userService,
                                        UserRepository userRepository,
                                        IInteractiveQuestion interactive,
                                        StockRepository stockRepository,
                                        CommonMessages commonMessages,
                                        FeaturesService featuresService,
                                        BaseParameters baseParameters,
                                        EmployeeCard employee = null
                                        ) : base(uowBuilder, unitOfWorkFactory, navigation, validator)
        {
            this.autofacScope    = autofacScope ?? throw new ArgumentNullException(nameof(autofacScope));
            this.userRepository  = userRepository ?? throw new ArgumentNullException(nameof(userRepository));
            this.interactive     = interactive;
            this.commonMessages  = commonMessages ?? throw new ArgumentNullException(nameof(commonMessages));
            this.featuresService = featuresService ?? throw new ArgumentNullException(nameof(featuresService));
            this.baseParameters  = baseParameters ?? throw new ArgumentNullException(nameof(baseParameters));
            var entryBuilder = new CommonEEVMBuilderFactory <Expense>(this, Entity, UoW, navigation, autofacScope);

            if (UoW.IsNew)
            {
                Entity.CreatedbyUser = userService.GetCurrentUser(UoW);
                Entity.Operation     = ExpenseOperations.Employee;
            }
            if (Entity.Operation != ExpenseOperations.Employee)
            {
                throw new InvalidOperationException("Диалог предназначен только для операций выдачи сотруднику.");
            }

            if (employee != null)
            {
                Entity.Employee  = UoW.GetById <EmployeeCard>(employee.Id);
                Entity.Warehouse = Entity.Employee.Subdivision?.Warehouse;
            }

            if (Entity.Warehouse == null)
            {
                Entity.Warehouse = stockRepository.GetDefaultWarehouse(UoW, featuresService, autofacScope.Resolve <IUserService>().CurrentUserId);
            }
            if (employee != null)
            {
                FillUnderreceived();
            }

            if (Entity.WriteOffDoc != null)
            {
                FillAktNumber();
            }

            WarehouseEntryViewModel = entryBuilder.ForProperty(x => x.Warehouse)
                                      .UseViewModelJournalAndAutocompleter <WarehouseJournalViewModel>()
                                      .UseViewModelDialog <WarehouseViewModel>()
                                      .Finish();
            EmployeeCardEntryViewModel = entryBuilder.ForProperty(x => x.Employee)
                                         .UseViewModelJournalAndAutocompleter <EmployeeJournalViewModel>()
                                         .UseViewModelDialog <EmployeeViewModel>()
                                         .Finish();

            var parameter = new TypedParameter(typeof(ExpenseEmployeeViewModel), this);

            DocItemsEmployeeViewModel = this.autofacScope.Resolve <ExpenseDocItemsEmployeeViewModel>(parameter);
            Entity.PropertyChanged   += EntityChange;

            //Переопределяем параметры валидации
            Validations.Clear();
            Validations.Add(new ValidationRequest(Entity, new ValidationContext(Entity, new Dictionary <object, object> {
                { nameof(BaseParameters), baseParameters }
            })));
        }
Пример #27
0
 public virtual void AddValidation(ValidateReturn validation)
 {
     dations.Add(validation);
 }