139 lines
5.8 KiB
C#
139 lines
5.8 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Web;
|
|
using Weee.Models;
|
|
using Weee.Models.ExtensionMethods;
|
|
using Weee.Models.Paramemter;
|
|
using Weee.ViewModels;
|
|
|
|
namespace Weee.Supports
|
|
{
|
|
public class DataFilter
|
|
{
|
|
public List<LCA> FilterLca(IEnumerable<LCA> lcas, string searchString)
|
|
{
|
|
var filteredLcas = new List<LCA>();
|
|
|
|
if (searchString == "") { return lcas.ToList(); }
|
|
|
|
foreach (var lca in lcas)
|
|
{
|
|
var ownerName = lca.Owner == null ? "" : lca.Owner.Name;
|
|
var verifyBy = lca.VerifyBy == null ? "" : lca.VerifyBy.Name;
|
|
//DL-19 begin
|
|
var description = lca.Description == null ? "" : lca.Description ;
|
|
var createdDate = lca.CreatedDate == null ? null : lca.CreatedDate.ToString();
|
|
var startDate = lca.StartDate == null ? null : lca.StartDate.ToString();
|
|
var endDate = lca.EndDate == null ? null : lca.EndDate.ToString();
|
|
var deadLine = lca.DeadLine == null ? null : lca.DeadLine.ToString();
|
|
var lcaTypeDisplayName = lca.LCATypeDisplayName == null ? "" : lca.LCATypeDisplayName.ToString();
|
|
var status = lca.Status + "";
|
|
var toBeSearch = (ownerName + " " + verifyBy + " " + description+ " " + createdDate + " " + startDate + " " + endDate + " " + deadLine + " " +
|
|
lcaTypeDisplayName + " " + status).ToLower();
|
|
//var toBeSearch = (ownerName + " " +
|
|
// verifyBy + " " +
|
|
// lca.Description.ToString() + " " +
|
|
// lca.CreatedDate.ToString() + " " +
|
|
// lca.StartDate.ToString() + " " +
|
|
// lca.EndDate.ToString() + " " +
|
|
// lca.DeadLine.ToString() + " " +
|
|
// lca.LCATypeDisplayName + " " +
|
|
// lca.Status.ToString()).ToLower();
|
|
//end
|
|
if (toBeSearch.Contains(searchString.ToLower())) { filteredLcas.Add(lca); }
|
|
}
|
|
|
|
return filteredLcas;
|
|
}
|
|
|
|
public List<Company> FilterCompany(List<Company> companies, string searchString)
|
|
{
|
|
var filteredCompanies = new List<Company>();
|
|
|
|
if (searchString == "") { return companies; }
|
|
|
|
foreach (var company in companies)
|
|
{
|
|
var toBeSearch = (company.Name + " " +
|
|
company.Address + " " +
|
|
company.Status.DisplayString() + " " +
|
|
company.CompanyTypeDisplayName).ToLower();
|
|
|
|
if (toBeSearch.Contains(searchString.ToLower())) { filteredCompanies.Add(company); }
|
|
}
|
|
|
|
return filteredCompanies;
|
|
}
|
|
|
|
public List<CompanyViewModel> FilterCompany(List<CompanyViewModel> companies, string searchString)
|
|
{
|
|
var filteredCompanies = new List<CompanyViewModel>();
|
|
|
|
if (searchString == "") { return companies; }
|
|
|
|
foreach (var company in companies)
|
|
{
|
|
var toBeSearch = (company.Name + " " +
|
|
company.Address + " " +
|
|
company.Status.DisplayString() + " " +
|
|
company.CompanyTypeDisplayName).ToLower();
|
|
|
|
if (toBeSearch.Contains(searchString.ToLower())) { filteredCompanies.Add(company); }
|
|
}
|
|
|
|
return filteredCompanies;
|
|
}
|
|
public List<NonYearlyParameterType> FilterNonYearlyParameterType(List<NonYearlyParameterType> nonYearlyParameterTypes, string searchString)
|
|
{
|
|
var filteredNonYearlyParameterTypes = new List<NonYearlyParameterType>();
|
|
|
|
if (searchString == "") { return nonYearlyParameterTypes; }
|
|
|
|
foreach (var nonYearlyParameterType in nonYearlyParameterTypes)
|
|
{
|
|
var parameterValue = nonYearlyParameterType.Parameters.Count != 0 ? nonYearlyParameterType.Parameters.First().Value.ToString() : "";
|
|
var toBeSearch = (nonYearlyParameterType.DisplayName + " " +
|
|
nonYearlyParameterType.Category.DisplayName + " " +
|
|
parameterValue).ToLower();
|
|
if (toBeSearch.Contains(searchString.ToLower())) { filteredNonYearlyParameterTypes.Add(nonYearlyParameterType); }
|
|
}
|
|
|
|
return filteredNonYearlyParameterTypes;
|
|
}
|
|
|
|
public List<Product> FilterProduct(IEnumerable<Product> products, string searchString)
|
|
{
|
|
var filteredProducts = new List<Product>();
|
|
|
|
if (searchString == "") { return products.ToList(); }
|
|
|
|
foreach (var product in products)
|
|
{
|
|
var toBeSearch = (product.Name + " " +
|
|
product.SpecDescription + " " +
|
|
product.SerialNumber).ToLower();
|
|
if (toBeSearch.Contains(searchString.ToLower())) { filteredProducts.Add(product); }
|
|
}
|
|
|
|
return filteredProducts;
|
|
}
|
|
|
|
public List<Fab> FilterFab(IEnumerable<Fab> fabs, string searchString)
|
|
{
|
|
var filteredFabs = new List<Fab>();
|
|
|
|
if (searchString == "") { return fabs.ToList(); }
|
|
|
|
foreach (var fab in fabs)
|
|
{
|
|
var toBeSearch = (fab.Name + " " +
|
|
fab.Phone + " " +
|
|
fab.Address).ToLower();
|
|
if (toBeSearch.Contains(searchString.ToLower())) { filteredFabs.Add(fab); }
|
|
}
|
|
|
|
return filteredFabs;
|
|
}
|
|
}
|
|
} |