コード例 #1
0
        // GET
        public ActionResult Find(int?page = 1, string sort = "Id", string sortDir = "ASC")
        {
            //LoggerFactory.CreateLog().Debug(string.Format(CultureInfo.InvariantCulture, "Presentation Layer - FindMedida Controller Begin"));

            try
            {
                // Add find logic here
                MedidaFindViewModel model;

                if (Request.IsAjaxRequest() && TempData.ContainsKey("FilterMedida"))
                {
                    model = (MedidaFindViewModel)TempData.Peek("FilterMedida");
                    var filtros     = GenerateExpression(model);
                    var pagedResult = _serviceMedida.FindPagedByFilter(filtros, null, page != null ? (int)page : model.PageIndex, model.PageSize, sort, sortDir, null, null);
                    model.Paginate(pagedResult, "");

                    //var pagedResult = _serviceMedida.FindPagedByFilter(new CustomQuery<Medida> { SerializedExpression = model.Filter }, null, page != null ? (int)page : model.PageIndex, model.PageSize, sort, sortDir == "ASC", null);
                    //model.Paginate(pagedResult, model.Filter);

                    //LoggerFactory.CreateLog().Debug(string.Format(CultureInfo.InvariantCulture, "Presentation Layer - FindPagedMedida Controller End"));
                    return(PartialView("_MedidaFindPartialView", model));
                }
                else
                {
                    TempData.Remove("FilterMedida");
                    model = new MedidaFindViewModel(_serviceMedida, _serviceFactConv);
                    //LoggerFactory.CreateLog().Debug(string.Format(CultureInfo.InvariantCulture, "Presentation Layer - FindMedida Controller End"));
                    return(View("MedidaFindView", model));
                }
            }
            catch (Exception ex)
            {
                //LoggerFactory.CreateLog().Error(string.Format(CultureInfo.InvariantCulture, "Presentation Layer - FindMedida Controller ERROR"), ex);
            }

            return(RedirectToAction("Index", "Home"));
        }