I have the following foreach statement and it return all the value from my array(customerConfigTypes). I only want to return only specific value.
What I'm trying to do is if my Array(customerConfigTypes) has a value "A" and my model(m.ConfigurationType) is of value A I only want to return that specific type.
So the word Contain doesn't seen to be used in the best context.... What will be the best way to do this?
var customerConfigTypes = new
Models.ReportConfiguration.ReportConfigurationType[]
{
ReportConfigurationType.CustomerFlagReport,
ReportConfiguration.ReportConfigurationType.SalesReport,
};
@foreach (var vm in Model.Where(m =>customerConfigTypes.Contains(m.ConfigurationType) &&
m.ReportConfigurationId > 0 ))
{
<div class="title-card @if (!hasCreateReportPermission) {<text> disabled</text> }">
<a class="inner" href="@Url.Action("Index", "ReportsAngular", new { area = "Angular", ReportType="CustomerFlagReport", ConfigurationId=vm.ReportConfigurationId, CanConfigureReports = hasCreateReportPermission })#/">
<i class="fa fa-wrench"></i>
<h3 class="panel-title">@vm.ConfigurationName</h3>
<p>@vm.ConfigurationDescription</p>
</a>
</div>
Here is my model layout
public class ReportConfigurationViewModel : IReportConfigurationViewModel, IXmlSerializable
{
public int? ReportConfigurationId { get; set; }
public string ConfigurationName { get; set; }
public string ConfigurationDescription { get; set; }
public bool IsTemplate { get; set; }
public ReportConfigurationType ConfigurationType { get; set; }
public String ReportTitle { get; set; }
public virtual IEnumerable<IFilterViewModel> Filters { get; set; }
public IEnumerable<IFilterViewModel> SelectedFilters { get; set; }
public IEnumerable<IReportingColumnViewModel> SelectedColumns { get; set; }
public IEnumerable<IReportSummaryColumnViewModel> SelectedReportSummaryColumns { get; set; }
public IEnumerable<IReportGroupingColumnViewModel> SelectedReportGroupingColumns { get; set; }
public IEnumerable<IReportSortingColumnViewModel> SelectedReportSortingColumns { get; set; }
public string ModeType { get; set; }
public bool SuppressReportSummaryTitles { get; set; }
public bool SuppressPageSummaryTitles { get; set; }
public bool SuppressGroupSummaryTitles { get; set; }
public System.Xml.Schema.XmlSchema GetSchema() { return null; }
foreachif you are only expecting one result?