Example #1
0
        public override bool Equals(object obj)
        {
            if (obj == null || GetType() != obj.GetType())
            {
                return(false);
            }

            UserRequestModel item = obj as UserRequestModel;

            return(item.StartRowIndex == this.StartRowIndex &&
                   item.ShownRowsCount == this.ShownRowsCount &&
                   item.SearchText == this.SearchText &&
                   item.OrderColumnName == this.OrderColumnName &&
                   item.SortOrder == this.SortOrder);
        }
Example #2
0
        public ActionResult Get([ModelBinder(typeof(DataTablesBinder))] IDataTablesRequest requestModel)
        {
            var userRequestModel = new UserRequestModel(requestModel.Start,
                                                        requestModel.Length,
                                                        requestModel.Search.Value,
                                                        requestModel.Columns.GetSortedColumns().First().Data,
                                                        requestModel.Columns.GetSortedColumns().First().SortDirection);
            var datatablesResponse = _cache.Get(userRequestModel);

            if (datatablesResponse == null)
            {
                datatablesResponse = GetDataFromDatabase(requestModel);
                _cache.Add(userRequestModel, datatablesResponse);
            }
            else
            {
                //Draw property has to be renewed each Get
                datatablesResponse = new DataTablesResponse(requestModel.Draw, datatablesResponse.data, datatablesResponse.recordsFiltered, datatablesResponse.recordsTotal);
            }

            return(Json(datatablesResponse, JsonRequestBehavior.AllowGet));
        }