public UnscResultDTO GetUnscListWithPaging(string PipelineDuns, string keyword, DateTime?postStartDate, DateTime?effectiveStartDate, DateTime?effectiveEndDate, SortingPagingInfo sortingPagingInfo) { UnscResultDTO unscResult = new UnscResultDTO(); //Get unsc list using above parameters IQueryable <UnscPerTransaction> result; IQueryable <UnscPerTransactionDTO> UnscDTO = null; try { result = GetAllUNSCOnPipelineId(PipelineDuns, keyword, postStartDate, effectiveStartDate, effectiveEndDate); if (result.Count() > 0) { UnscDTO = GetUnscData(result).AsQueryable(); } var dataQueryWithOrder = SortByColumnWithOrder(UnscDTO, sortingPagingInfo); unscResult.RecordCount = dataQueryWithOrder.Count(); var resultData = dataQueryWithOrder.Skip((sortingPagingInfo.CurrentPageIndex - 1) * sortingPagingInfo.PageSize).Take(sortingPagingInfo.PageSize).ToList(); if (resultData.Count() > 0) { unscResult.unscPerTransactionDTO = resultData.Select(a => modalFactory.ParseDTO(a)).ToList(); return(unscResult); } return(new UnscResultDTO()); } catch (Exception ex) { return(null); } }
public async System.Threading.Tasks.Task <SearchCriteriaUNSC> GetAllUnscDataAsync(SearchCriteriaUNSC criteria) { try { List <UnscPerTransactionDTO> list = new List <UnscPerTransactionDTO>(); UnscResultDTO unscResult = new UnscResultDTO(); //_client.BaseUrl = new Uri("http://localhost:56676"); var request = new RestRequest(string.Format("GetUnscByCriteria"), Method.POST) { RequestFormat = DataFormat.Json }; request.JsonSerializer = NewtonsoftJsonSerializer.Default; request.AddJsonBody(criteria); var response = client.Execute <UnscResultDTO>(request); if (response.Data != null) { list = response.Data.unscPerTransactionDTO; criteria.RecordCount = response.Data.RecordCount; } else { list = new List <UnscPerTransactionDTO>(); criteria.RecordCount = 0; } criteria.UnscPerTransactionViewModel = list; return(criteria); } catch (Exception ex) { return(null); } }
public IHttpActionResult GetUnscByCriteria([FromBody] UnscDataFilter criteria) { var source = (dynamic)null; try { //SortingPagingInfo sortingPagingInfo = new SortingPagingInfo(); //sortingPagingInfo.SortField = criteria.sort; //sortingPagingInfo.SortDirection = criteria.SortDirection; //sortingPagingInfo.PageSize = criteria.size; //sortingPagingInfo.CurrentPageIndex = criteria.page; //UprdUnscRepository uprdUnscRepository = new UprdUnscRepository(); var pTime = criteria.postTime.GetValueOrDefault().TimeOfDay; UprdDbEntities1 db = new UprdDbEntities1(); var query = db.UnscPerTransactions.Where(a => a.TransactionServiceProvider == criteria.PipelineDuns).AsQueryable(); if (!string.IsNullOrEmpty(criteria.keyword)) { query = query.Where(a => a.Loc.Contains(criteria.keyword) || a.LocName.Contains(criteria.keyword)); } if (!string.IsNullOrEmpty(criteria.postStartDate.ToString()) && TimeSpan.MinValue != pTime) { query = query.Where(a => DbFunctions.TruncateTime(a.PostingDateTime) == DbFunctions.TruncateTime(criteria.postStartDate) && DbFunctions.CreateTime(a.PostingDateTime.Value.Hour, a.PostingDateTime.Value.Minute, a.PostingDateTime.Value.Second) >= pTime); } if (!string.IsNullOrEmpty(criteria.EffectiveStartDate.ToString())) { query = query.Where(a => DbFunctions.TruncateTime(a.EffectiveGasDayTime) == DbFunctions.TruncateTime(criteria.EffectiveStartDate)); } if (!string.IsNullOrEmpty(criteria.EffectiveEndDate.ToString())) { query = query.Where(a => DbFunctions.TruncateTime(a.EndingEffectiveDay) == DbFunctions.TruncateTime(criteria.EffectiveEndDate)); } var data = query.Select(a => new UnscPerTransactionDTO { TransactionID = a.TransactionID, //AvailablePercentage= ChangePercentage = a.ChangePercentage, CreatedDate = a.CreatedDate, DUNSNo = a.TransactionServiceProvider, EffectiveGasDay = a.EffectiveGasDayTime, //EffectiveGasDayTime=a.EffectiveGasDayTime, EndingEffectiveDay = a.EndingEffectiveDay, Loc = a.Loc, LocName = a.LocName, LocPurpDesc = a.LocPurpDesc, LocQTIDesc = a.LocQTIDesc, LocZn = a.LocZn, MeasBasisDesc = a.MeasBasisDesc, PipelineID = a.PipelineID, //PipelineNameDuns=a. PostingDate = a.PostingDateTime, //PostingDateTime=a.PostingDateTime, TotalDesignCapacity = a.TotalDesignCapacity, TransactionServiceProvider = a.TransactionServiceProvider, TransactionServiceProviderPropCode = a.TransactionServiceProviderPropCode, UnsubscribeCapacity = a.UnsubscribeCapacity }).ToList(); UnscResultDTO result = new UnscResultDTO(); result.unscPerTransactionDTO = (data != null && data.Count > 0) ? data : new List <UnscPerTransactionDTO>(); result.RecordCount = (data != null && data.Count > 0) ? data.Count : 0; source = result; // if (!string.IsNullOrEmpty(criteria.PipelineDuns)) // { // source = uprdUnscRepository.GetUnscListWithPaging(criteria.PipelineDuns, criteria.keyword, criteria.postStartDate, criteria.EffectiveStartDate, criteria.EffectiveEndDate, sortingPagingInfo); // } // int count = sortingPagingInfo.PageCount; // int CurrentPage = sortingPagingInfo.CurrentPageIndex; // int PageSize = sortingPagingInfo.PageSize; // int TotalCount = count; // int TotalPages = (int)Math.Ceiling(count / (double)PageSize); // // if CurrentPage is greater than 1 means it has previousPage // var previousPage = CurrentPage > 1 ? "Yes" : "No"; // // if TotalPages is greater than CurrentPage means it has nextPage // var nextPage = CurrentPage < TotalPages ? "Yes" : "No"; // // Object which we are going to send in header // var paginationMetadata = new // { // totalCount = TotalCount, // pageSize = PageSize, // currentPage = CurrentPage, // totalPages = TotalPages, // previousPage, // nextPage // }; // // Setting Header // HttpContext.Current.Response.Headers.Add("Paging-Headers", JsonConvert.SerializeObject(paginationMetadata)); } catch (Exception ex) { throw ex; } //if (source == null) //{ // var resp = new HttpResponseMessage(HttpStatusCode.NotFound) // { // ReasonPhrase = "Records Not Found." // }; // throw new HttpResponseException(resp); //} return(Ok(source)); }