Example #1
0
        //private static QueryObject<UserPasswords> GenerateExpression(UserPasswordsFindViewModel model)
        private static IEnumerable <filterRule> GenerateExpression(UserPasswordsFindViewModel 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.UserPasswords.Id.HasValue)
                {
                    filtros.Add(new filterRule()
                    {
                        op = "equal", field = "Id", value = model.UserPasswords.Id.Value.ToString()
                    });
                }
                //And(d => d.Id == model.UserPasswords.Id.Value);
                if (model.UserPasswords.IdUsuario.HasValue)
                {
                    filtros.Add(new filterRule()
                    {
                        op = "equal", field = "IdUsuario", value = model.UserPasswords.IdUsuario.Value.ToString()
                    });
                }
                //And(d => d.IdUsuario == model.UserPasswords.IdUsuario.Value);
                if (model.UserPasswords.IdPassword.HasValue)
                {
                    filtros.Add(new filterRule()
                    {
                        op = "equal", field = "IdPassword", value = model.UserPasswords.IdPassword.Value.ToString()
                    });
                }
                //And(d => d.IdPassword == model.UserPasswords.IdPassword.Value);
                if (model.UserPasswords.ExternalUser.HasValue)
                {
                    filtros.Add(new filterRule()
                    {
                        op = "equal", field = "ExternalUser", value = model.UserPasswords.ExternalUser.Value.ToString()
                    });
                }
                //And(d => d.ExternalUser == model.UserPasswords.ExternalUser.Value);
            }

            return(filtros);
            //return new QueryObject<UserPasswords>(expression ?? (d => true));
        }
Example #2
0
        public ActionResult Find(UserPasswordsFindViewModel model)
        {
            //LoggerFactory.CreateLog().Debug(string.Format(CultureInfo.InvariantCulture, "Presentation Layer - FindUserPasswords 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 = _serviceUserPasswords.FindPagedByFilter(filtros, null, 1, model.PageSize, model.OrderBy, "Asc", null, null);
                    model.Paginate(pagedResult, "");

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

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

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

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

            ModelState.AddModelError("", PresentationResources.Error);
            return(View("UserPasswordsFindView", new UserPasswordsFindViewModel(_serviceUserPasswords, _servicePassword, _serviceUsuario)));
        }
Example #3
0
        // GET
        public ActionResult Find(int?page = 1, string sort = "Id", string sortDir = "ASC")
        {
            //LoggerFactory.CreateLog().Debug(string.Format(CultureInfo.InvariantCulture, "Presentation Layer - FindUserPasswords Controller Begin"));

            try
            {
                // Add find logic here
                UserPasswordsFindViewModel model;

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

                    //var pagedResult = _serviceUserPasswords.FindPagedByFilter(new CustomQuery<UserPasswords> { 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 - FindPagedUserPasswords Controller End"));
                    return(PartialView("_UserPasswordsFindPartialView", model));
                }
                else
                {
                    TempData.Remove("FilterUserPasswords");
                    model = new UserPasswordsFindViewModel(_serviceUserPasswords, _servicePassword, _serviceUsuario);
                    //LoggerFactory.CreateLog().Debug(string.Format(CultureInfo.InvariantCulture, "Presentation Layer - FindUserPasswords Controller End"));
                    return(View("UserPasswordsFindView", model));
                }
            }
            catch (Exception ex)
            {
                //LoggerFactory.CreateLog().Error(string.Format(CultureInfo.InvariantCulture, "Presentation Layer - FindUserPasswords Controller ERROR"), ex);
            }

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