Exemple #1
0
        private void SetBranchNoRule()
        {
            if (HttpMethod == HttpMethod.Post || RequestJsonDictionary.ContainsKey("branch_no"))
            {
                Store store = null;

                RuleFor(x => x.P_BranchNo)
                .NotNull()
                .NotEmpty()
                .Must(id => id > 0)
                .WithMessage("branch_no required")
                .DependentRules(() => RuleFor(dto => dto.P_BranchNo)
                                .Must(id =>
                {
                    if (store == null)
                    {
                        store = _storeHelper.GetValidStore(id.GetValueOrDefault());
                    }

                    return(store != null);
                }).WithMessage("invalid branch_no")
                                );
            }
        }
Exemple #2
0
        private void SetStoreIdRule()
        {
            if (HttpMethod == HttpMethod.Post || RequestJsonDictionary.ContainsKey("store_id"))
            {
                Store store = null;

                RuleFor(x => x.StoreId)
                .NotNull()
                .NotEmpty()
                .Must(id => id > 0)
                .WithMessage("store_id required")
                .DependentRules(() => RuleFor(dto => dto.StoreId)
                                .Must(id =>
                {
                    if (store == null)
                    {
                        store = _storeHelper.GetValidStore(id);
                    }

                    return(store != null);
                }).WithMessage("invalid store_id")
                                );
            }
        }