Ejemplo n.º 1
0
        public static DynamicParameters GetSearchParams(Models.Database.BaseSearchParams filterParams)
        {
            if (filterParams == null)
            {
                throw new ArgumentNullException("Invalid params.");
            }

            if (filterParams.StartIndex < 0)
            {
                throw new ArgumentOutOfRangeException("StartIndex could not be less than zero.");
            }

            if (filterParams.PageSize < 1)
            {
                throw new ArgumentOutOfRangeException("PageSize could not be less than one.");
            }

            //Get token param
            var p = GetToken(filterParams.Token);

            //Pagination
            p.Add("@StartIndex", filterParams.StartIndex, System.Data.DbType.Int32);
            p.Add("@PageSize", filterParams.PageSize, System.Data.DbType.Byte);

            int actualSize = 0;

            p.Add("@ActualSize", actualSize, System.Data.DbType.Int32, System.Data.ParameterDirection.Output);

            return(p);
        }
Ejemplo n.º 2
0
        public void Setup()
        {
            _token        = "UserDBToken";
            _filterParams = new Models.Database.BaseSearchParams()
            {
                Token      = _token,
                PageSize   = 10,
                StartIndex = 0
            };

            _data = new Models.Database.BaseDataModelWithToken()
            {
                Token = _token
            };

            _outputParams = new DynamicParameters();
        }
Ejemplo n.º 3
0
        public static DynamicParameters GetSearchParams(Models.Database.BaseSearchParams filterParams)
        {
            if (filterParams == null)
            {
                throw new ArgumentNullException("خطا در نحوه ارسال درخواست رخ داده است");
            }
            if (filterParams.StartIndex < 0 || (filterParams.StartIndex == 0 && filterParams.PageSize <= 0))
            {
                throw new ArgumentException("خطا در نحوه ارسال درخواست رخ داده است");
            }
            var p = GetSearchParams(filterParams.Token);

            //Pagination
            p.Add("@StartIndex", filterParams.StartIndex, System.Data.DbType.Int32);
            p.Add("@PageSize", filterParams.PageSize, System.Data.DbType.Int32);
            p.Add("@Sort", filterParams.Sort, System.Data.DbType.String);

            int actualSize = 0;

            p.Add("@ActualSize", actualSize, System.Data.DbType.Int32, System.Data.ParameterDirection.Output);

            return(p);
        }