示例#1
0
        //private static QueryObject<RendCant> GenerateExpression(RendCantFindViewModel model)
        private static IEnumerable <filterRule> GenerateExpression(RendCantFindViewModel model)
        {
            //LoggerFactory.CreateLog().Debug(string.Format(CultureInfo.InvariantCulture, "Presentation Layer - FindAlim Controller Begin"));
            //var filters = JsonConvert.DeserializeObject<IEnumerable<filterRule>>(filterRules);
            //return Json(pagelist, JsonRequestBehavior.AllowGet);
            IList <filterRule> filtros = new List <filterRule>();

            if (model != null)
            {
                if (model.RendCant.Id.HasValue)
                {
                    filtros.Add(new filterRule()
                    {
                        op = "equal", field = "Id", value = model.RendCant.Id.Value.ToString()
                    });
                }
                //And(d => d.Id == model.RendCant.Id.Value);
                if (model.RendCant.IdAlim.HasValue)
                {
                    filtros.Add(new filterRule()
                    {
                        op = "equal", field = "IdAlim", value = model.RendCant.IdAlim.Value.ToString()
                    });
                }
                //And(d => d.IdAlim == model.RendCant.IdAlim.Value);
                if (model.RendCant.IdRend.HasValue)
                {
                    filtros.Add(new filterRule()
                    {
                        op = "equal", field = "IdRend", value = model.RendCant.IdRend.Value.ToString()
                    });
                }
                //And(d => d.IdRend == model.RendCant.IdRend.Value);
                if (model.RendCant.Cantidad.HasValue)
                {
                    filtros.Add(new filterRule()
                    {
                        op = "equal", field = "Cantidad", value = model.RendCant.Cantidad.Value.ToString()
                    });
                }
                //And(d => d.Cantidad == model.RendCant.Cantidad.Value);
                if (model.RendCant.FechaRegistro.HasValue)
                {
                    filtros.Add(new filterRule()
                    {
                        op = "equal", field = "FechaRegistro", value = model.RendCant.FechaRegistro.Value.ToString()
                    });
                }
                //And(d => d.FechaRegistro == model.RendCant.FechaRegistro.Value);
            }

            return(filtros);
            //return new QueryObject<RendCant>(expression ?? (d => true));
        }
示例#2
0
        public ActionResult Find(RendCantFindViewModel model)
        {
            //LoggerFactory.CreateLog().Debug(string.Format(CultureInfo.InvariantCulture, "Presentation Layer - FindRendCant Controller Begin"));
            //int totalCount = 0;

            try
            {
                // Add find logic here
                if (ModelState.IsValid)
                {
                    if (model.OrderBy == null)
                    {
                        model.OrderBy = "Id";
                    }

                    string sort        = "Id";
                    var    filtros     = GenerateExpression(model);
                    var    pagedResult = _serviceRendCant.FindPagedByFilter(filtros, null, 1, model.PageSize, model.OrderBy, "Asc", null, null);
                    model.Paginate(pagedResult, "");

                    //var RendCantDetails = _serviceAlim.Query(
                    //    new RendCantQuery().Withfilter(filtros))
                    //    .OrderBy(n => n.OrderBy("Id", "Asc"))
                    //    .SelectPage(1, model.PageSize, out totalCount);
                    //var pagelist = new { total = totalCount, rows = RendCantDetails.ToList() };

                    //var pagedResult = _serviceRendCant.FindPagedByFilter(expression, includes, 1, model.PageSize, "Id", model.OrderBy, model.Ascendent, null, null);
                    //model.Paginate(pagedResult, expression.SerializedExpression);

                    TempData.Clear();
                    TempData.Add("FilterRendCant", model);

                    //LoggerFactory.CreateLog().Debug(string.Format(CultureInfo.InvariantCulture, "Presentation Layer - FindRendCant Controller End"));
                    return(PartialView("_RendCantFindPartialView", model));
                }
            }
            catch (Exception ex)
            {
                //LoggerFactory.CreateLog().Error(string.Format(CultureInfo.InvariantCulture, "Presentation Layer - FindRendCant Controller ERROR"), ex);
            }

            ModelState.AddModelError("", PresentationResources.Error);
            return(View("RendCantFindView", new RendCantFindViewModel(_serviceRendCant, _serviceAlim, _serviceRend)));
        }
示例#3
0
        // GET
        public ActionResult Find(int?page = 1, string sort = "Id", string sortDir = "ASC")
        {
            //LoggerFactory.CreateLog().Debug(string.Format(CultureInfo.InvariantCulture, "Presentation Layer - FindRendCant Controller Begin"));

            try
            {
                // Add find logic here
                RendCantFindViewModel model;

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

                    //var pagedResult = _serviceRendCant.FindPagedByFilter(new CustomQuery<RendCant> { 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 - FindPagedRendCant Controller End"));
                    return(PartialView("_RendCantFindPartialView", model));
                }
                else
                {
                    TempData.Remove("FilterRendCant");
                    model = new RendCantFindViewModel(_serviceRendCant, _serviceAlim, _serviceRend);
                    //LoggerFactory.CreateLog().Debug(string.Format(CultureInfo.InvariantCulture, "Presentation Layer - FindRendCant Controller End"));
                    return(View("RendCantFindView", model));
                }
            }
            catch (Exception ex)
            {
                //LoggerFactory.CreateLog().Error(string.Format(CultureInfo.InvariantCulture, "Presentation Layer - FindRendCant Controller ERROR"), ex);
            }

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