Exemplo n.º 1
0
 private void SetSortingProperties(ReadListRequest listRequest)
 {
     if (!string.IsNullOrEmpty(_viewModel.SortColumn))
     {
         listRequest.SortField = _viewModel.SortColumn;
         listRequest.SortDirection = _viewModel.SortDirection.ToLowerInvariant() == "asc" ? "Ascending" : "Descending";
     }
 }
Exemplo n.º 2
0
        private void SetFilteringProperties(ReadListRequest listRequest)
        {
            var keywordFilterValue = string.IsNullOrEmpty(_viewModel.FilterFields.Single(f => f.FieldName == "Keyword").FieldValue) ? string.Empty : _viewModel.FilterFields.Single(f => f.FieldName == "Keyword").FieldValue;
            if (!string.IsNullOrEmpty(keywordFilterValue))
                listRequest.Keyword = keywordFilterValue;

            var enabledFilterValue = string.IsNullOrEmpty(_viewModel.FilterFields.Single(f => f.FieldName == "Enabled").FieldValue) ? string.Empty : _viewModel.FilterFields.Single(f => f.FieldName == "Enabled").FieldValue;
            if (!string.IsNullOrEmpty(enabledFilterValue) && enabledFilterValue != "All")
                listRequest.IsEnabled = enabledFilterValue == "Enabled";

            var topicFilterValue = _viewModel.FilterFields.Single(f => f.FieldName == "EventTopic");
            if (topicFilterValue.SelectedOption != null)
            {
                listRequest.EventTopicId = int.Parse(topicFilterValue.SelectedOption.Id.ToString(), CultureInfo.InvariantCulture);
            }

            var typeFilterValue = _viewModel.FilterFields.Single(f => f.FieldName == "EventType");
            if (typeFilterValue.SelectedOption != null)
            {
                listRequest.EventTypeId = int.Parse(typeFilterValue.SelectedOption.Id.ToString(), CultureInfo.InvariantCulture);
            }

            var createdDateValue = string.IsNullOrEmpty(_viewModel.FilterFields.Single(f => f.FieldName == "CreatedDate").FieldValue) ?
                string.Empty :
                _viewModel.FilterFields.Single(f => f.FieldName == "CreatedDate").FieldValue;
            if (!string.IsNullOrEmpty(createdDateValue))
            {
                DateTime tempDate;

                if (DateTime.TryParse(createdDateValue, out tempDate))
                {
                    listRequest.CreatedDate = tempDate;
                }
            }

            var publishedDateValue = string.IsNullOrEmpty(_viewModel.FilterFields.Single(f => f.FieldName == "PublishedDate").FieldValue) ?
                string.Empty :
                _viewModel.FilterFields.Single(f => f.FieldName == "PublishedDate").FieldValue;
            if (!string.IsNullOrEmpty(publishedDateValue))
            {
                DateTime tempDate;

                if (DateTime.TryParse(publishedDateValue, out tempDate))
                {
                    listRequest.PublishedDate = tempDate;
                }
            }

            var orgUnitFilterValue = _viewModel.FilterFields.Single(f => f.FieldName == "OrgUnit");
            if (orgUnitFilterValue.SelectedOption != null)
            {
                listRequest.OrgUnitId = int.Parse(orgUnitFilterValue.SelectedOption.Id.ToString(), CultureInfo.InvariantCulture);
            }
        }
Exemplo n.º 3
0
 private void SetPagingProperties(ReadListRequest listRequest)
 {
     listRequest.PageSize = _viewModel.PageSize;
     listRequest.RequestedPage = _viewModel.PageNumber;
 }
Exemplo n.º 4
0
        private ReadListResponse QueryData()
        {
            var listRequest = new ReadListRequest();

            //Paging
            SetPagingProperties(listRequest);

            //Sorting
            SetSortingProperties(listRequest);

            //Filters
            SetFilteringProperties(listRequest);

            return ProcessRequest<ReadListResponse>(listRequest);
        }