Exemple #1
0
        public ActionResult Find(LoginAttemptsFindViewModel model)
        {
            //LoggerFactory.CreateLog().Debug(string.Format(CultureInfo.InvariantCulture, "Presentation Layer - FindLoginAttempts 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 = _serviceLoginAttempts.FindPagedByFilter(filtros, null, 1, model.PageSize, model.OrderBy, "Asc", null, null);
                    model.Paginate(pagedResult, "");

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

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

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

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

            ModelState.AddModelError("", PresentationResources.Error);
            return(View("LoginAttemptsFindView", new LoginAttemptsFindViewModel(_serviceLoginAttempts, _serviceUsuario)));
        }
Exemple #2
0
        // GET
        public ActionResult Find(int?page = 1, string sort = "Id", string sortDir = "ASC")
        {
            //LoggerFactory.CreateLog().Debug(string.Format(CultureInfo.InvariantCulture, "Presentation Layer - FindLoginAttempts Controller Begin"));

            try
            {
                // Add find logic here
                LoginAttemptsFindViewModel model;

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

                    //var pagedResult = _serviceLoginAttempts.FindPagedByFilter(new CustomQuery<LoginAttempts> { 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 - FindPagedLoginAttempts Controller End"));
                    return(PartialView("_LoginAttemptsFindPartialView", model));
                }
                else
                {
                    TempData.Remove("FilterLoginAttempts");
                    model = new LoginAttemptsFindViewModel(_serviceLoginAttempts, _serviceUsuario);
                    //LoggerFactory.CreateLog().Debug(string.Format(CultureInfo.InvariantCulture, "Presentation Layer - FindLoginAttempts Controller End"));
                    return(View("LoginAttemptsFindView", model));
                }
            }
            catch (Exception ex)
            {
                //LoggerFactory.CreateLog().Error(string.Format(CultureInfo.InvariantCulture, "Presentation Layer - FindLoginAttempts Controller ERROR"), ex);
            }

            return(RedirectToAction("Index", "Home"));
        }
Exemple #3
0
        //private static QueryObject<LoginAttempts> GenerateExpression(LoginAttemptsFindViewModel model)
        private static IEnumerable <filterRule> GenerateExpression(LoginAttemptsFindViewModel 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.LoginAttempts.Id.HasValue)
                {
                    filtros.Add(new filterRule()
                    {
                        op = "equal", field = "Id", value = model.LoginAttempts.Id.Value.ToString()
                    });
                }
                //And(d => d.Id == model.LoginAttempts.Id.Value);
                if (model.LoginAttempts.IdUsuario.HasValue)
                {
                    filtros.Add(new filterRule()
                    {
                        op = "equal", field = "IdUsuario", value = model.LoginAttempts.IdUsuario.Value.ToString()
                    });
                }
                //And(d => d.IdUsuario == model.LoginAttempts.IdUsuario.Value);
                if (!string.IsNullOrEmpty(model.LoginAttempts.Password))
                {
                    filtros.Add(new filterRule()
                    {
                        op = "equal", field = "Password", value = model.LoginAttempts.Password
                    });
                }
                //And(d => d.Password.Contains(model.LoginAttempts.Password));
                if (!string.IsNullOrEmpty(model.LoginAttempts.IPNumber))
                {
                    filtros.Add(new filterRule()
                    {
                        op = "equal", field = "IPNumber", value = model.LoginAttempts.IPNumber
                    });
                }
                //And(d => d.IPNumber.Contains(model.LoginAttempts.IPNumber));
                if (!string.IsNullOrEmpty(model.LoginAttempts.BrowserType))
                {
                    filtros.Add(new filterRule()
                    {
                        op = "equal", field = "BrowserType", value = model.LoginAttempts.BrowserType
                    });
                }
                //And(d => d.BrowserType.Contains(model.LoginAttempts.BrowserType));
                if (model.LoginAttempts.Success.HasValue)
                {
                    filtros.Add(new filterRule()
                    {
                        op = "equal", field = "Success", value = model.LoginAttempts.Success.Value.ToString()
                    });
                }
                //And(d => d.Success == model.LoginAttempts.Success.Value);
                if (model.LoginAttempts.CreatedDate.HasValue)
                {
                    filtros.Add(new filterRule()
                    {
                        op = "equal", field = "CreatedDate", value = model.LoginAttempts.CreatedDate.Value.ToString()
                    });
                }
                //And(d => d.CreatedDate == model.LoginAttempts.CreatedDate.Value);
            }

            return(filtros);
            //return new QueryObject<LoginAttempts>(expression ?? (d => true));
        }