Ejemplo n.º 1
0
        public void Render(IEnumerable <TModel> rows, TableRequestModel model,
                           ControllerContext context)
        {
            context.HttpContext.Response.ContentType = ContentType;
            var columns = _tableDefinition.Columns.Where(c => c.ShowRawValue).ToArray();
            var writer  = new StreamWriter(context.HttpContext.Response.OutputStream);

            writer.Write(BeginColumnsValue);
            for (var i = 0; i < columns.Length; i++)
            {
                writer.Write(WrapText(columns[i].Name));
                if (i < (columns.Length - 1))
                {
                    writer.Write(ValueDelimiter);
                }
            }
            writer.Write(EndColumnsValue);
            writer.Write(BeginRowsValue);
            var aRows = rows.ToArray();

            for (var r = 0; r < aRows.Length; r++)
            {
                var row = aRows[r];
                writer.Write(BeginRowValue);
                for (var i = 0; i < columns.Length; i++)
                {
                    writer.Write(WrapText(columns[i].GetRawValue(row)));
                    if (i < (columns.Length - 1))
                    {
                        writer.Write(ValueDelimiter);
                    }
                }
                writer.Write(EndRowValue);
            }
            writer.Write(EndRowsValue);
            writer.Write(ClosingValue);
            writer.Flush();
        }
Ejemplo n.º 2
0
 public TableUrlManager(string actionUrl, TableRequestModel requestModel, NameValueCollection routeValues)
 {
     _actionUrl = actionUrl;
     _urlParams = routeValues.Merge(requestModel);
 }
Ejemplo n.º 3
0
 public TableResult <DefaultMvcTable <TModel>, TModel> Default(TableRequestModel model, int totalRows)
 {
     return(new TableResult <DefaultMvcTable <TModel>, TModel>(_model, totalRows, model));
 }
Ejemplo n.º 4
0
 public TableResult <TTable, TModel> Build <TTable>(TableRequestModel model, int totalRows) where TTable : MvcTable <TModel>
 {
     return(new TableResult <TTable, TModel>(_model, totalRows, model));
 }
Ejemplo n.º 5
0
        public ActionResult ListCavesForFilters(TableRequestModel request, FilteredCavesViewModel model)
        {
            request.PageSize = request.PageSize ?? 10;
            //var caves = db.Caves;
            IQueryable<Cave> caves = db.Caves;
            //var mainPredicate = PredicateBuilder.True<Cave>();
            if(model.HideCodelessItems)
            {
                caves = caves.Where(p => p.SasaCode != null);
            }
            if(!string.IsNullOrEmpty(model.SearchText))
            {
                caves = caves.Where(p => p.Name.Contains(model.SearchText) || p.Description.Contains(model.SearchText));
            }
            if(!string.IsNullOrEmpty(model.SelectedCaveAttributes))
            {
                //var attributePredicate = PredicateBuilder.True<Cave>();
                var caveAttributeList = model.SelectedCaveAttributes.Split(',').ToList();
                foreach (var item in caveAttributeList.Where(p => p != "null"))
                {
                    caves = caves.Where(p => p.CaveAttributes.Any(x => x.CaveAttributeId == item));
                    //attributePredicate = attributePredicate.Or(p=> p.CaveAttributes.Contains(new CaveAttribute(){CaveAttributeID = item}));
                }
                //mainPredicate = mainPredicate.And(attributePredicate);
            }
            if (!string.IsNullOrEmpty(model.SelectedCaveStatuses))
            {
                var caveStatusList = model.SelectedCaveStatuses.Split(',').ToList();

                foreach (var item in caveStatusList.Where(p=> p != "null"))
                {
                    caves = caves.Where(p=> p.CaveStatuses.Any(x=> x.CaveStatusId == item ));
                    //statusPredicate = statusPredicate.Or(p => p.CaveStatuses.Any(x=> x.CaveStatusID == item));
                }
                //caves = caves.Where(statusPredicate);
                //mainPredicate = mainPredicate.And(statusPredicate);
            }
            if (!string.IsNullOrEmpty(model.SelectedExplorationStatus))
            {
                caves = caves.Where(p => p.ExplorationStatusId == model.SelectedExplorationStatus);
            }
            if (!string.IsNullOrEmpty(model.SelectedLocationStatus))
            {
                //mainPredicate.And(p => p.LocationStatusID == model.SelectedLocationStatus);
                caves = caves.Where(p => p.LocationStatusId == model.SelectedLocationStatus);
            }

            //if (!String.IsNullOrEmpty(model.SelectedCustomerId))
            //{
            //	orders = orders.Where(o => o.CustomerID == model.SelectedCustomerId);
            //}
            //caves = caves.Where(mainPredicate);

            //var mycaves = caves.ToList();
            return TableResult.From(caves).Build<CaveFilterTable>(request);
        }
Ejemplo n.º 6
0
 public TableUrlManager(string actionUrl, TableRequestModel requestModel, NameValueCollection routeValues)
 {
     _actionUrl = actionUrl;
     _urlParams = routeValues.Merge(requestModel);
 }
Ejemplo n.º 7
0
 public static IEnumerable <TModel> PaginateRows <TModel>(this IEnumerable <TModel> rows, TableRequestModel model)
 {
     return
         (rows.SortBy(model.SortColumn, model.SortAscending)
          .Skip(model.PageSize * (model.PageNumber - 1))
          .Take(model.PageSize));
 }
 public ActionResult ListVisitHistories(TableRequestModel request, VisitHistoriesViewModel model)
 {
     IQueryable<VisitHistory> vh = db.VisitHistories.Where(p => p.CaveId == model.CaveID);
     return TableResult.From(vh).Build<VisitHistoryTable>(request);
 }
 public ActionResult ListCaveFiles(TableRequestModel request, CaveFilesModel model)
 {
     var caveFiles = db.Caves.Find(model.CaveID).MetaFiles;// MetaFiles.Where(p => p.CaveID == model.CaveID);
     return TableResult.From(caveFiles).Build<CaveFileTable>(request,1); //TODO - SOrt out this total rows thing.. that is currently set to 1
 }
 public ActionResult ListObservation(TableRequestModel request, ObservationsModel model)
 {
     var observations = db.Observations.Where(p => p.VisitHistoryId == model.VisitHistoryID);
     return TableResult.From(observations).Build<ObservationTable>(request);
 }
 public ActionResult ListPublications(TableRequestModel request, PublicationsViewModel model)
 {
     var publications = db.Publications.Where(p => p.PublicationEntityId == model.PublicationEntityID);
     return TableResult.From(publications).Build<PublicationTable>(request);
 }
Ejemplo n.º 12
0
 public TableResult <DefaultMvcTable <TModel>, TModel> Default(TableRequestModel model)
 {
     return(new TableResult <DefaultMvcTable <TModel>, TModel>(_model, model));
 }