public LocationsResultDTO GetLocationByPipeline(string pipelineDuns) { LocationsResultDTO locResult = new LocationsResultDTO(); var locationResult = DbContext.Locations.Where(a => a.PipeDuns == pipelineDuns).ToList(); locResult.locationsDTO = locationResult.Select(a => modalFactory.Parse(a)).OrderBy(a => a.Name).ToList(); locResult.RecordCount = locResult.locationsDTO.Count(); return(locResult); }
public LocationsResultDTO AddLocsNotInTblLoc(string pipelineDuns) { LocationsResultDTO result = new LocationsResultDTO(); result = _ILocationRepository.GetLocFromOacyUnsc(pipelineDuns); return(result); }
public LocationsResultDTO GetLocFromOacyUnsc(string Pipelineduns) { LocationsResultDTO locationsResultDTO = new LocationsResultDTO(); var pipeId = DbContext.Pipeline.Where(a => a.DUNSNo == Pipelineduns).Select(p => p.ID); var Res = ((from unsc in DbContext.UnscPerTransaction join l in DbContext.Location on new { unsc.Loc, Column1 = unsc.Loc, unsc.LocName, unsc.TransactionServiceProvider } equals new { Loc = l.Identifier, Column1 = l.PropCode, LocName = l.Name, TransactionServiceProvider = l.PipeDuns } into l_join from l in l_join.DefaultIfEmpty() where (l.Identifier == null || l.PropCode == null) && l.Name == null && l.PropCode == null && l.PipeDuns == null && unsc.TransactionServiceProvider == Pipelineduns group unsc by new { unsc.Loc, unsc.LocName, unsc.TransactionServiceProvider } into g select new { g.Key.LocName, g.Key.Loc, g.Key.TransactionServiceProvider }).Union (from oacy in DbContext.OACYPerTransaction join l in DbContext.Location on new { oacy.Loc, Column1 = oacy.Loc, oacy.LocName, oacy.TransactionServiceProvider } equals new { Loc = l.Identifier, Column1 = l.PropCode, LocName = l.Name, TransactionServiceProvider = l.PipeDuns } into l_join from l in l_join.DefaultIfEmpty() where (l.Identifier == null || l.PropCode == null) && l.Name == null && l.PropCode == null && l.PipeDuns == null && oacy.TransactionServiceProvider == Pipelineduns group oacy by new { oacy.Loc, oacy.LocName, oacy.TransactionServiceProvider } into g select new { LocName = g.Key.LocName, Loc = g.Key.Loc, TransactionServiceProvider = g.Key.TransactionServiceProvider })); var Result = (from r in Res select new LocationsDTO() { Name = r.LocName, RDB = null, Identifier = r.Loc, PropCode = r.Loc, //RDUsageID = 0, PipelineDuns = r.TransactionServiceProvider }).ToList(); foreach (var item in Result) { if (item.RDUsageID == 1) { item.RDB = "R"; } else if (item.RDUsageID == 2) { item.RDB = "D"; } else { item.RDB = "B"; } } locationsResultDTO.locationsDTO = (Result != null || Result.Count > 0) ? Result : new List <LocationsDTO>(); locationsResultDTO.RecordCount = Result.Count(); return(locationsResultDTO); }
// PageNo = 0,1,2,3...so on. public LocationsResultDTO GetLocationsWithPaging(string Keyword, string PipelineDuns, string PopupFor, bool IsSpecialDelCase, SortingPagingInfo sortingPagingInfo) { LocationsResultDTO locationsResultDTO = new LocationsResultDTO(); List <Location> Result = new List <Location>(); int PageNo = sortingPagingInfo.CurrentPageIndex; int PageSize = sortingPagingInfo.PageSize; int NotRDB = 1; // for not Receipt locs. if (PopupFor == "RecLoc" || PopupFor == "Receipt" || PopupFor == "ContractPath" || PopupFor == "Supply") { NotRDB = 2; // for not delivery locs. if (string.IsNullOrEmpty(Keyword)) { var QueryableData = DbContext.Location.Where(a => a.PipeDuns == PipelineDuns && a.IsActive == true && a.RDUsageID != NotRDB); var QueryableDataWithOrder = GetQueryableDataWithOrder(QueryableData, sortingPagingInfo); sortingPagingInfo.PageCount = QueryableDataWithOrder.Count(); Result = QueryableDataWithOrder.Skip((PageNo - 1) * PageSize).Take(PageSize).ToList(); } else { var QueryableDataWithKeyword = DbContext.Location.Where(a => a.PipeDuns == PipelineDuns && a.IsActive == true && a.RDUsageID != NotRDB && (a.Identifier.Contains(Keyword) || a.PropCode.Contains(Keyword) || a.Name.Contains(Keyword))); var QueryableDataWithOrder = GetQueryableDataWithOrder(QueryableDataWithKeyword, sortingPagingInfo); sortingPagingInfo.PageCount = QueryableDataWithOrder.Count(); Result = QueryableDataWithOrder.Skip((PageNo - 1) * PageSize).Take(PageSize).ToList(); } } else { NotRDB = 1; // not-Receipt if (IsSpecialDelCase) { if (PipelineDuns == "006958581") // ANR Pipeline Company { // locationList = locationList.Where(a => a.PropCode == "103565" || a.PropCode == "103702").ToList(); if (string.IsNullOrEmpty(Keyword)) { Result = DbContext.Location.Where(a => a.PropCode == "103565" || a.PropCode == "103702").OrderBy(a => a.Name).Skip((PageNo - 1) * PageSize).Take(PageSize).ToList(); } else { Result = DbContext.Location.Where(a => (a.PropCode == "103565" || a.PropCode == "103702") && (a.Identifier.Contains(Keyword) || a.PropCode.Contains(Keyword) || a.Name.Contains(Keyword))).OrderBy(a => a.Name).Skip((PageNo - 1) * PageSize).Take(PageSize).ToList(); } } else if (PipelineDuns == "007933047") //Transwestern Pipeline Company, LLC { // locationList = locationList.Where(a => a.PropCode == "58646" || a.PropCode == "58647" || a.PropCode == "58648" || a.PropCode == "58649" || a.PropCode == "500543").ToList(); if (string.IsNullOrEmpty(Keyword)) { Result = DbContext.Location.Where(a => a.PropCode == "58646" || a.PropCode == "58647" || a.PropCode == "58648" || a.PropCode == "58649" || a.PropCode == "500543").OrderBy(a => a.Name).Skip((PageNo - 1) * PageSize).Take(PageSize).ToList(); } else { Result = DbContext.Location.Where(a => (a.PropCode == "58646" || a.PropCode == "58647" || a.PropCode == "58648" || a.PropCode == "58649" || a.PropCode == "500543") && (a.Identifier.Contains(Keyword) || a.PropCode.Contains(Keyword) || a.Name.Contains(Keyword))).OrderBy(a => a.Name).Skip((PageNo - 1) * PageSize).Take(PageSize).ToList(); } } else if (PipelineDuns == "829416002") // FAYETTEVILLE EXPRESS PIPELINE LLC { //locationList = locationList.Where(a => a.PropCode == "58744").ToList(); if (string.IsNullOrEmpty(Keyword)) { Result = DbContext.Location.Where(a => a.PropCode == "58744").OrderBy(a => a.Name).Skip((PageNo - 1) * PageSize).Take(PageSize).ToList(); } else { Result = DbContext.Location.Where(a => (a.PropCode == "58744") && (a.Identifier.Contains(Keyword) || a.PropCode.Contains(Keyword) || a.Name.Contains(Keyword))).OrderBy(a => a.Name).Skip((PageNo - 1) * PageSize).Take(PageSize).ToList(); } } else { if (string.IsNullOrEmpty(Keyword)) { Result = DbContext.Location.Where(a => a.PipeDuns == PipelineDuns && a.IsActive == true && a.RDUsageID != NotRDB).OrderBy(a => a.Name).Skip((PageNo - 1) * PageSize).Take(PageSize).ToList(); } else { Result = DbContext.Location.Where(a => a.PipeDuns == PipelineDuns && a.IsActive == true && a.RDUsageID != NotRDB && (a.Identifier.Contains(Keyword) || a.PropCode.Contains(Keyword) || a.Name.Contains(Keyword))).OrderBy(a => a.Name).Skip((PageNo - 1) * PageSize).Take(PageSize).ToList(); } } } else//If location is Delivery { if (string.IsNullOrEmpty(Keyword)) { var QueriableDelLocData = DbContext.Location.Where(a => a.PipeDuns == PipelineDuns && a.IsActive == true && a.RDUsageID != NotRDB); var QueryableDataWithOrderDelLoc = GetQueryableDataWithOrder(QueriableDelLocData, sortingPagingInfo); sortingPagingInfo.PageCount = QueryableDataWithOrderDelLoc.Count(); Result = QueryableDataWithOrderDelLoc.Skip((PageNo - 1) * PageSize).Take(PageSize).ToList(); } else { var QueriableDelLocDataWithData = DbContext.Location.Where(a => a.PipeDuns == PipelineDuns && a.IsActive == true && a.RDUsageID != NotRDB && (a.Identifier.Contains(Keyword) || a.PropCode.Contains(Keyword) || a.Name.Contains(Keyword))); var QueryableDataWithOrderDelLoc = GetQueryableDataWithOrder(QueriableDelLocDataWithData, sortingPagingInfo); sortingPagingInfo.PageCount = QueryableDataWithOrderDelLoc.Count(); Result = QueryableDataWithOrderDelLoc.Skip((PageNo - 1) * PageSize).Take(PageSize).ToList(); } } } locationsResultDTO.RecordCount = sortingPagingInfo.PageCount; locationsResultDTO.locationsDTO = Result.Select(a => modalFactory.Parse(a)).OrderBy(a => a.Name).ToList(); return(locationsResultDTO); }