public override void OnActionExecuting(ActionExecutingContext filterContext) { KinkTrackerEntities db = new KinkTrackerEntities(); PagedView myLogging = new PagedView(); myLogging.ControllerName = filterContext.ActionDescriptor.ControllerDescriptor.ControllerName; myLogging.ActionName = filterContext.ActionDescriptor.ActionName; myLogging.Date = filterContext.HttpContext.Timestamp; myLogging.IPAddress = filterContext.HttpContext.Request.UserHostAddress; myLogging.ActionParameters = ""; myLogging.AbsoluteUri = filterContext.HttpContext.Request.UrlReferrer?.AbsoluteUri; foreach (var pram in filterContext.ActionParameters) { myLogging.ActionParameters += pram + " "; } myLogging.ActionParameters = myLogging.ActionParameters.Trim(); db.PagedViews.Add(myLogging); try { db.SaveChanges(); } catch { return; } }
public ActionResult DeleteConfirmed(int id) { PagedView pagedView = db.PagedViews.Find(id); db.PagedViews.Remove(pagedView); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "ID,Date,IPAddress,ControllerName,ActionName,ActionParameters,AbsoluteUri,Notes")] PagedView pagedView) { if (ModelState.IsValid) { db.Entry(pagedView).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(pagedView)); }
public ActionResult Create([Bind(Include = "ID,Date,IPAddress,ControllerName,ActionName,ActionParameters,AbsoluteUri,Notes")] PagedView pagedView) { if (ModelState.IsValid) { db.PagedViews.Add(pagedView); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(pagedView)); }
public void Filter(Expression <Func <T, bool> > predicate, PagedView <T> pagedView) { var sortExpression = $"{ pagedView.Sort ?? "Id"} {pagedView.SortDir ?? "ASC"}"; var dbSet = DbSet().Where(predicate).OrderBy(sortExpression).AsQueryable(); pagedView.TotalRecords = dbSet.Count(); pagedView.RecordIndex = ((pagedView.Page ?? 1) - 1) * pagedView.PageSize; pagedView.ResultSet = dbSet.Skip(pagedView.RecordIndex).Take(pagedView.PageSize); }
public async Task <PagedView <CustomerDto> > GetPagedCustomers (string name, string cpf, string email, int page, int pageSize) { int totalItems = 0; PagedView <CustomerDto> result = new PagedView <CustomerDto>(); var offset = QueryCommon.OffSet(page, pageSize); string sql = @"SELECT FirstName + ' ' + LastName As Name, Email, Phone FROM dbo.CUSTOMER WHERE (Cpf = @Cpf OR ISNULL(@Cpf,'') = '') AND (Email = @Email OR ISNULL(@Email,'') = '') AND ((FirstName like @FirstName OR ISNULL(@FirstName,'') = '') OR (LastName like @LastName OR ISNULL(@LastName,'') = '')) "; string sqlPaged = QueryCommon.PagedQuery(orderBy: "Name", sql, offset, pageSize); string sqlTotalCount = QueryCommon.TotalItemsQuery(sql); var customers = await _database.GetConnection() .QueryAsync <CustomerDto>(sqlPaged, new { Cpf = cpf ?? string.Empty, Email = email ?? string.Empty, FirstName = $"%{name}%" ?? $"%{string.Empty}%", LastName = $"%{name}%" ?? $"%{string.Empty}%" }); totalItems = await _database.GetConnection() .ExecuteScalarAsync <int>(sqlTotalCount, new { Cpf = cpf ?? string.Empty, Email = email ?? string.Empty, FirstName = name ?? string.Empty, LastName = name ?? string.Empty }); result.Data = customers.ToList(); result.Page = page; result.PageSize = pageSize; result.TotalPages = totalItems / pageSize + (totalItems % pageSize == 0 ? 0 : 1); result.TotalItems = totalItems; return(result); }
// GET: Admin/PagedViews/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } PagedView pagedView = db.PagedViews.Find(id); if (pagedView == null) { return(HttpNotFound()); } return(View(pagedView)); }
public ActionResult Members(PagedView <Member> pagedView) { //var filterPattern = string.Format("%{0}%", pagedView.FilterKey ?? ""); //pagedView.Sort = pagedView.Sort ?? "EnrollmentDate"; //pagedView.SortDir = pagedView.SortDir ?? "DESC"; //DataLayer.Repository.Instance.Filter(x => (SqlFunctions.PatIndex(filterPattern, x.FirstName) > 0 // || SqlFunctions.PatIndex(filterPattern, x.Occupation) > 0 // || SqlFunctions.PatIndex(filterPattern, x.Mobile) > 0 // || SqlFunctions.PatIndex(filterPattern, x.Email) > 0 // || SqlFunctions.PatIndex(filterPattern, x.FatherName) > 0) // , pagedView); //return View(pagedView); return(View()); }
private static void onRemove(string key, object value, CacheItemRemovedReason reason) { if (!key.StartsWith("PV-")) { return; } KinkTrackerEntities db = new KinkTrackerEntities(); PagedView myLogging = new PagedView(); string[] keyValues = key.Replace("PV-", "").Split(new string[] { "->" }, StringSplitOptions.RemoveEmptyEntries); myLogging.ControllerName = keyValues[0]; myLogging.ActionName = keyValues[1]; myLogging.Date = DateTime.Now; db.PagedViews.Add(myLogging); db.SaveChanges(); }
public PagedView <Model.View.Poi.Poi> Get(PoiGetBinding binding) { using (var context = GetMainContext()) { int?categoryId = context.PoiCategories.GetId(binding.CategoryId); int?vendorId = context.Vendors.GetId(binding.VendorId); var pois = context.Pois.Include(x => x.PoiCategory) .WhereIf(categoryId.HasValue, x => x.PoiCategoryId == categoryId) .WhereIf(!string.IsNullOrWhiteSpace(binding.Name), x => x.Name.Contains(binding.Name)) .WhereIf(vendorId.HasValue, x => x.VendorPois.Any(y => y.VendorId == vendorId && x.Id == y.PoiId)) .WhereIf(binding.Search, x => x.Name.ToLower().Contains(binding.Search.ToLower())) .InsideRectangle(binding.X, binding.Y); var result = new PagedView <Model.View.Poi.Poi>(); result.Count = pois.Count(); result.Items = pois.OrderByDescending(x => x.Id) .Page(binding) .ToList() .Select(x => new Model.View.Poi.Poi(x)); return(result); } }
public ActionResult ShareHoldings(PagedView <ShareHolding> pagedView) { return(View()); }