public async Task <IEnumerable <Rate> > GetByRecipeIdAsync(int recipeId, RatesParameters parameters, bool asNoTracking = false) { var rates = _context.Rates.Where(x => x.RecipeId == recipeId && x.Deleted == false).AsQueryable(); if (parameters.CreatedAt != default(DateTime)) { rates = rates.Where(x => x.CreatedAt.Date == parameters.CreatedAt.Date); } if (!string.IsNullOrEmpty(parameters.Query)) { var descriptionFromQuery = parameters.Query.ToLowerInvariant(); rates = rates.Where(x => x.Description.ToLowerInvariant().Contains(descriptionFromQuery)); } if (parameters.Value != null) { rates = rates.Where(x => x.Value == parameters.Value); } if (asNoTracking) { rates = rates.AsNoTracking(); } return(await rates.ToListAsync()); }
public async Task <IActionResult> ReadRatesAsync(int id, RatesParameters parameters) { if (!string.IsNullOrWhiteSpace(parameters.Fields) && !PropertyManager.PropertiesExists <Rate>(parameters.Fields)) { return(BadRequest()); } var rates = await _rateService.GetByRecipeIdAsync(id, parameters, true); var ratesDto = _mapper.Map <IEnumerable <RateDto> >(rates); return(Ok(ratesDto.ShapeData(parameters.Fields))); }
public RatesProperties( DashboardHelper dashboardHelper, IGadget gadget, RatesParameters parameters, List <Grid> strataGridList, List <string> columnOrder ) { InitializeComponent(); this.DashboardHelper = dashboardHelper; this.Gadget = gadget; this.Parameters = parameters; this.StrataGridList = strataGridList; this.ColumnOrder = columnOrder; _numerFilter = new DataFilters(DashboardHelper); _denomFilter = new DataFilters(DashboardHelper); List <FieldInfo> items = new List <FieldInfo>(); List <string> fields = new List <string>(); fields.Add(string.Empty); items.Add(new FieldInfo() { Name = "", DataType = "", VariableCategory = VariableCategory.Field }); foreach (string fieldName in DashboardHelper.GetFieldsAsList()) { items.Add(new FieldInfo() { Name = fieldName, DataType = DashboardHelper.GetColumnDbType(fieldName).ToString(), VariableCategory = VariableCategory.Field }); fields.Add(fieldName); } foreach (string fieldName in DashboardHelper.GetAllGroupsAsList()) { FieldInfo fieldInfo = new FieldInfo() { Name = fieldName, DataType = String.Empty, VariableCategory = VariableCategory.Group }; items.Add(fieldInfo); } if (DashboardHelper.IsUsingEpiProject) { for (int i = 0; i < DashboardHelper.View.Pages.Count; i++) { items.Add(new FieldInfo() { Name = "Page " + (i + 1).ToString(), DataType = String.Empty, VariableCategory = VariableCategory.Page }); } } fields.Sort(); cmbNumeratorField.ItemsSource = items; cmbDenominatorField.ItemsSource = items; cmbGroupField.ItemsSource = fields; cmbSecondaryGroupField.ItemsSource = fields; foreach (string fieldName in fields) { lbxAvailableVariables.Items.Add(fieldName); } //nk CollectionView view = (CollectionView)CollectionViewSource.GetDefaultView(lvNumerator.ItemsSource); PropertyGroupDescription groupDescription = new PropertyGroupDescription("VariableCategory"); //nk view.GroupDescriptions.Add(groupDescription); RowFilterControl = new RowFilterControl(this.DashboardHelper, Dialogs.FilterDialogMode.ConditionalMode, (gadget as RatesControl).DataFilters, true); RowFilterControl.HorizontalAlignment = System.Windows.HorizontalAlignment.Left; panelFilters.Children.Add(RowFilterControl); #region Translation lblSelectNumeratorAggregateFunction.Content = DashboardSharedStrings.AGGREGATE_COLON; // Aggregate: lblNumerator.Content = DashboardSharedStrings.OF_COLON; // of: lblNumeratorWhere.Content = DashboardSharedStrings.AND_WHERE; // And Where: (filter condition - optional) checkBoxNumberatorDistinct.Content = DashboardSharedStrings.DISTINCT; // Distinct lblPER.Content = DashboardSharedStrings.PER; // PER lblSelectDenominatorAggregateFunction.Content = DashboardSharedStrings.AGGREGATE_COLON; // Aggregate: lblDenominator.Content = DashboardSharedStrings.OF_COLON; // of: lblDenominatorWhere.Content = DashboardSharedStrings.AND_WHERE; // And Where: (filter condition - optional) checkBoxDenominatorDistinct.Content = DashboardSharedStrings.DISTINCT; // Distinct tblockVariableDenominator.Content = DashboardSharedStrings.DENOMINATOR_COLON; // Denominator: lblRateMultiplier.Content = DashboardSharedStrings.RATE_MULTIPLIER_COLON; // Rate Multiplier: defaultColorOption.Content = DashboardSharedStrings.USE_DEFAULT_COLOR; // Use default color btnDenominatorRule.Content = DashboardSharedStrings.CREATE_EDIT_CONDITION; // Create/Edit Condition btnNumeratorRule.Content = DashboardSharedStrings.CREATE_EDIT_CONDITION; // Create/Edit Condition lblConfigExpandedTitle.Content = DashboardSharedStrings.GADGET_CONFIG_TITLE_RATES; tbtnVariables.Title = DashboardSharedStrings.DEFINE_RATE;; tbtnVariables.Description = DashboardSharedStrings.CREATE_RULES_TO_DEFINE_A_RATE; // Create rules to define a rate. tbtnSorting.Title = DashboardSharedStrings.GADGET_TABBUTTON_SORTING; tbtnSorting.Description = DashboardSharedStrings.GADGET_TABDESC_SORTING; tbtnDisplay.Title = DashboardSharedStrings.GADGET_TABBUTTON_DISPLAY; tbtnDisplay.Description = DashboardSharedStrings.GADGET_TABDESC_DISPLAY; tbtnFilters.Title = DashboardSharedStrings.GADGET_TABBUTTON_FILTERS; tbtnFilters.Description = DashboardSharedStrings.GADGET_TABDESC_FILTERS; tblockPanelVariables.Content = DashboardSharedStrings.DEFINE_RATE; //"Define Rate"; tblockPanelDisplay.Content = DashboardSharedStrings.GADGET_PANELHEADER_DISPLAY; tblockPanelSorting.Content = DashboardSharedStrings.GADGET_PANELHEADER_SORTING; tblockPanelDataFilter.Content = DashboardSharedStrings.GADGET_PANELHEADER_DATA_FILTER; tblockGroupingSubheader.Content = DashboardSharedStrings.GADGET_PANELSUBHEADER_GROUPING; tblockSortingSubheader.Content = DashboardSharedStrings.GADGET_PANELSUBHEADER_SORTING; tblockSortMethod.Content = DashboardSharedStrings.GADGET_SORT_METHOD; tblockTitle.Content = DashboardSharedStrings.GADGET_GADET_TITLE; tblockDesc.Content = DashboardSharedStrings.GADGET_DESCRIPTION; tblockPanelOutputOpt.Content = DashboardSharedStrings.GADGET_OUTPUT_OPTIONS; tblockAnyFilterGadgetOnly.Content = DashboardSharedStrings.GADGET_FILTER_GADGET_ONLY; tblockVariableDenominator.Content = DashboardSharedStrings.GADGET_VARIABLES_DENOMINATOR; tblockGroupby.Content = DashboardSharedStrings.GADGET_GROUP_BY; tblockSubGroupBy.Content = DashboardSharedStrings.GADGET_SUBGROUP_BY; tblockAvailableVariables.Content = DashboardSharedStrings.GADGET_AVAILABLE_VARIABLES; tblockSortOrder.Content = DashboardSharedStrings.GADGET_SORT_ORDER; tblockDimensions.Content = DashboardSharedStrings.GADGET_DIMENSIONS; tblockTitleNDescSubheader.Content = DashboardSharedStrings.GADGET_PANELSUBHEADER_TITLENDESC; tblockMaxWidth.Text = DashboardSharedStrings.GADGET_MAX_WIDTH; btnOK.Content = DashboardSharedStrings.BUTTON_OK; btnCancel.Content = DashboardSharedStrings.BUTTON_CANCEL; tblockMaxRows.Text = SharedStrings.DASHBOARD_OPTION_MAX_ROWS; #endregion // Translation }