/// <summary> /// Provides a list of Contract Subdistributor as a result of filtering the DB on specific filters /// </summary> /// <returns></returns> public List <ContractSubdistributor> FilteredItems() { ResultManager.IsCorrect = false; List <ContractSubdistributor> items = new List <ContractSubdistributor>(); try { // implementing filtering pipeline var contractSubistributorList = RetrieveAllToFilter(); ContractSubdistributorFilteringPipeline pipeline = new ContractSubdistributorFilteringPipeline(); if (Identity.CurrentUser.IsInRole(UserRole.EmployeeManagerOperation + "," + UserRole.EmployeeManagerView + "," + UserRole.EmployeeRTVOperation + "," + UserRole.EmployeeRTVView)) { EmployeeController employee = new EmployeeController(Configurations); List <string> zones = employee.GetBayerEmployeeZones(CurrentUser.Id); pipeline.Register(new RegisteredZoneNameListFilter(zones)); //pipeline.Register(new AssignedGRVFilter(CurrentUser.Id)); } items = pipeline.Process(contractSubistributorList).ToList(); ResultManager.IsCorrect = true; } catch (Exception ex) { ResultManager.Add(ErrorDefault, Trace + "Index.311: Error while retrieving ContractSubdistributor list from DB: " + ex.Message); } return(items); }
public ActionResult FilterBySubdistributorId() { // get the ContractDistributor list var contractSubdistributorList = controller.RetrieveAllToFilter(); // Construct the pipeline ContractSubdistributorFilteringPipeline contractSubdistributorPipelline = new ContractSubdistributorFilteringPipeline(); // Register the filters to be executed contractSubdistributorPipelline.Register(new SubdistributorIdFilter(1)); // Start pipeline processing var filteredcontractSubdistributors = contractSubdistributorPipelline.Process(contractSubdistributorList); // At this point fetch data from DB var listedContractSubdistributors = filteredcontractSubdistributors.ToList(); // just sending the result for testing purposes, cannot serialize the entire object because of the circular references present from EF. // (this is the same behavior with previous approach) var result = listedContractSubdistributors.Select(x => new ContractSubdistributor { Id = x.Id, IdB = x.IdB, ContractSubdistributorStatusId = x.ContractSubdistributorStatusId, RegisteredZoneName = x.RegisteredZoneName, RegisteredRegionName = x.RegisteredRegionName }); string JsonResult = JsonConvert.SerializeObject(result, Formatting.Indented, new JsonSerializerSettings { PreserveReferencesHandling = PreserveReferencesHandling.Objects }); return(Content(JsonResult)); }
/// <summary> /// Provides a list of Contract Subdistributor as a result of filtering the DB on specific filters /// </summary> /// <returns></returns> public List <ContractSubdistributor> FilteredItems() { ResultManager.IsCorrect = false; List <ContractSubdistributor> items = new List <ContractSubdistributor>(); try { // implementing filtering pipeline var contractSubistributorList = RetrieveAllToFilter(); ContractSubdistributorFilteringPipeline pipeline = new ContractSubdistributorFilteringPipeline(); EmployeeController employee = new EmployeeController(Configurations); int subdistributorId = employee.GetSubdistributorId(CurrentUser.Id); pipeline.Register(new SubdistributorIdFilter(subdistributorId)); items = pipeline.Process(contractSubistributorList).ToList(); ResultManager.IsCorrect = true; } catch (Exception ex) { ResultManager.Add(ErrorDefault, Trace + "Index.311: Error while retrieving ContractSubdistributor list from DB: " + ex.Message); } return(items); }