public HttpResponseMessage GetDatasets(int pageIndex, int itemsPerPage) { DomainInstance handler = new DomainInstance(); var datasets = handler.GetDataSets(string.Empty, true, null, pageIndex, itemsPerPage)?.Select(dataset => new { dataset.Name, dataset.ID, dataset.Username, Status = dataset.Status.GetEnumString(), dataset.IsValid, Source = dataset.PointsSource.ToString() }); var response = new HttpResponseMessage(); response.Content = new StringContent(datasets.JSONSerialize()); response.Content.Headers.ContentType = new MediaTypeHeaderValue("application/json"); return(response); }
public HttpResponseMessage GetDatasetsList(int pageIndex, int itemsPerPage = -1) { if (itemsPerPage == -1) { itemsPerPage = ChoseDatasetViewModel.DataPointsPerPage; } var databaseInteractionHandler = new DomainInstance(); var response = new HttpResponseMessage(); bool isAnonymous = User.IsInRole(UserRoles.Anonymous.GetEnumString()); List <Tuple <DataSetsFilters, string> > filters = buildFilters <DataSetsFilters>(Request.GetQueryNameValuePairs()); //if is anonymous, only source filter should be considered if (isAnonymous) { filters = filters.Where(item => item.Item1 == DataSetsFilters.Source).ToList(); filters.Add(new Tuple <DataSetsFilters, string>(DataSetsFilters.IsDemo, "1")); } var model = databaseInteractionHandler.GetDataSets( RouteConfig.CurrentUser.Username, isAnonymous, filters, pageIndex, itemsPerPage )?.Select(dataset => new { dataset.Name, dataset.ID, dataset.Username, Status = dataset.Status.GetEnumString(), dataset.IsValid }); response.Content = new StringContent(model?.JSONSerialize()); response.Content.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("application/json"); return(response); }
public ActionResult GetChoseDatasetPage() { try { DomainInstance databaseInteractionHandler = new DomainInstance(); return(View("~/Views/Home/Points Settings Content/ChoseDataset.cshtml", new ChoseDatasetViewModel(databaseInteractionHandler.GetDataSets( RouteConfig.CurrentUser?.Username, false, new List <Tuple <DataSetsFilters, string> >() { new Tuple <DataSetsFilters, string>( DataSetsFilters.None, string.Empty) }, ChoseDatasetViewModel.DataPointsPerPage )))); } catch (Exception e) { return(View()); } }