Пример #1
0
        public ActionResult Index(int?page, MeasureSearchModel Model)
        {
            Model.searchResultModel   = new List <MeasureViewModel>();
            Model.searchResultModel   = _measureBL.Search(Model);
            Session[ScreenController] = Model;
            var pageNumber = (page ?? 1);
            var list       = Model.searchResultModel.ToPagedList(pageNumber, 50);

            return(PartialView("ListMeasure", list));
        }
Пример #2
0
        /// <summary>
        /// Prepare measure search model
        /// </summary>
        /// <param name="searchModel">Measure search model</param>
        /// <returns>Measure search model</returns>
        public virtual MeasureSearchModel PrepareMeasureSearchModel(MeasureSearchModel searchModel)
        {
            if (searchModel == null)
            {
                throw new ArgumentNullException(nameof(searchModel));
            }

            //prepare nested search models
            PrepareMeasureDimensionSearchModel(searchModel.MeasureDimensionSearchModel);
            PrepareMeasureWeightSearchModel(searchModel.MeasureWeightSearchModel);

            return(searchModel);
        }
        /// <summary>
        /// Prepare measure search model
        /// </summary>
        /// <param name="searchModel">Measure search model</param>
        /// <returns>
        /// A task that represents the asynchronous operation
        /// The task result contains the measure search model
        /// </returns>
        public virtual Task <MeasureSearchModel> PrepareMeasureSearchModelAsync(MeasureSearchModel searchModel)
        {
            if (searchModel == null)
            {
                throw new ArgumentNullException(nameof(searchModel));
            }

            //prepare nested search models
            PrepareMeasureDimensionSearchModel(searchModel.MeasureDimensionSearchModel);
            PrepareMeasureWeightSearchModel(searchModel.MeasureWeightSearchModel);

            return(Task.FromResult(searchModel));
        }
Пример #4
0
        public int Count(MeasureSearchModel model)
        {
            int    result   = 0;
            string strQuery = "SELECT COUNT( `id`) FROM product_measure WHERE 1";

            if (!string.IsNullOrEmpty(model.code) || !string.IsNullOrEmpty(model.name))
            {
                strQuery += (!string.IsNullOrEmpty(model.code)) ? " AND `code` LIKE @code" : "";
                strQuery += (!string.IsNullOrEmpty(model.name)) ? " AND `name` LIKE @name" : "";
            }
            result = (_db.ExecuteScalar <int>(strQuery, new { code = '%' + model.code + '%', name = '%' + model.name + '%' }));
            return(result);
        }
Пример #5
0
        public List <MeasureViewModel> Search(MeasureSearchModel model)
        {
            string strQuery = "SELECT `id`, `code`, `name`, `description`";

            strQuery += " FROM product_measure WHERE 1";
            if (!string.IsNullOrEmpty(model.code) || !string.IsNullOrEmpty(model.name))
            {
                strQuery += (!string.IsNullOrEmpty(model.code)) ? " AND `code` LIKE @code" : "";
                strQuery += (!string.IsNullOrEmpty(model.name)) ? " AND `name` LIKE @name" : "";
            }
            var result = _db.Query <MeasureViewModel>(strQuery, new { code = '%' + model.code + '%', name = '%' + model.name + '%' }).ToList();

            return(result);
        }
Пример #6
0
        public ActionResult Index()
        {
            MeasureSearchModel Model = new MeasureSearchModel();

            if (Session[ScreenController] != null)
            {
                Model = (MeasureSearchModel)Session[ScreenController];
                Model.searchResultModel = new List <MeasureViewModel>();
                Model.searchResultModel = _measureBL.Search(Model).ToPagedList(1, 50);
            }
            else
            {
                Model.searchResultModel = new List <MeasureViewModel>().ToPagedList(1, 50);
            }
            return(View(Model));
        }
Пример #7
0
        public ActionResult Index(int?page, MeasureSearchModel Model)
        {
            Model.searchResultModel = new List <MeasureViewModel>();
            Model.searchResultModel = _measureBL.Search(Model);
            int Count = _measureBL.Count(Model);

            TempData["SearchCount"] = Count + " row(s)";
            if (page.HasValue && Session[ScreenController] != null)
            {
                Model = (MeasureSearchModel)Session[ScreenController];
            }
            else
            {
                Session[ScreenController] = Model;
            }
            var pageNumber = (page ?? 1);

            ViewBag.No = (pageNumber - 1) * 50;
            var list = Model.searchResultModel.ToPagedList(pageNumber, 50);

            return(PartialView("ListMeasure", list));
        }
Пример #8
0
 public List <MeasureViewModel> Search(MeasureSearchModel model)
 {
     return(_measureDAO.Search(model));
 }
Пример #9
0
 public int Count(MeasureSearchModel model)
 {
     return(_measureDAO.Count(model));
 }