public IHttpActionResult GetPaginatedList([FromBody] IList <FilterModel> filters, Kapsch.Gateway.Models.Shared.Enums.FilterJoin filterJoin, bool asc, string orderPropertyName, int pageIndex, int pageSize) { using (var dbContext = new Kapsch.RTE.Data.DataContext()) { var totalCount = 0; var filter = filters.Select(f => FilterConverter.Convert(f)).ToList(); var func = ExpressionBuilder.GetExpression <CameraPointData>(filter, (Core.Filters.FilterJoin)filterJoin); var query = dbContext .CameraPointsData .AsNoTracking(); if (func != null) { query = query.Where(func); } var orderedQuery = asc ? query.OrderByMember(PropertyHelper.GetSortingValue <CameraPointData>(orderPropertyName)) : query.OrderByMemberDescending(PropertyHelper.GetSortingValue <CameraPointData>(orderPropertyName)); var resultsToSkip = (pageIndex - 1) * pageSize; var pageResults = orderedQuery .Skip(resultsToSkip) .Take(pageSize) .GroupBy(f => new { Total = query.Count() }) .FirstOrDefault(); var entities = new List <CameraPointData>(); if (pageResults != null) { totalCount = pageResults.Key.Total; entities = pageResults.ToList(); } var totalPages = Math.Ceiling(totalCount / (float)pageSize); var paginationList = new PaginationListModel <AtPointModel>(); foreach (CameraPointData cameraPointData in entities) { AtPointModel model = JsonConvert.DeserializeObject <AtPointModel>(cameraPointData.Json); paginationList.Models.Add(model); } paginationList.TotalCount = totalCount; return(Ok(paginationList)); } }
public IHttpActionResult GetTerminalPaginatedList([FromBody] IList <FilterModel> filters, Kapsch.Gateway.Models.Shared.Enums.FilterJoin filterJoin, bool asc, string orderPropertyName, int pageIndex, int pageSize) { using (var dbContext = new DataContext()) { var totalCount = 0; var filter = filters.Select(f => FilterConverter.Convert(f)).ToList(); var func = ExpressionBuilder.GetExpression <Data.PaymentTerminal>(filter, (Kapsch.Core.Filters.FilterJoin)filterJoin); var query = dbContext .PaymentTerminals .AsNoTracking(); if (func != null) { query = query.Where(func); } var orderedQuery = asc ? query.OrderByMember(PropertyHelper.GetSortingValue <PaymentTerminalModel>(orderPropertyName)) : query.OrderByMemberDescending(PropertyHelper.GetSortingValue <PaymentTerminalModel>(orderPropertyName)); var resultsToSkip = (pageIndex - 1) * pageSize; var pageResults = orderedQuery .Skip(resultsToSkip) .Take(pageSize) .GroupBy(f => new { Total = query.Count() }) .FirstOrDefault(); var entities = new List <PaymentTerminal>(); if (pageResults != null) { totalCount = pageResults.Key.Total; entities = pageResults.ToList(); } var paginationList = new PaginationListModel <PaymentTerminalModel>(); paginationList.PageIndex = pageIndex; paginationList.PageSize = pageSize; paginationList.Models = entities.Select(f => new PaymentTerminalModel { ID = f.ID, ModifiedTimestamp = f.ModifiedTimestamp, Status = (Models.Enums.Status)f.Status, TerminalType = (Models.Enums.TerminalType)f.TerminalType, UUID = f.UUID }) .ToList(); paginationList.TotalCount = totalCount; return(Ok(paginationList)); } }
public IHttpActionResult GetSystemRolePaginatedList([FromBody] IList <FilterModel> filters, Kapsch.Gateway.Models.Shared.Enums.FilterJoin filterJoin, bool asc, string orderPropertyName, int pageIndex, int pageSize, bool includeFunctions) { using (var dbContext = new DataContext()) { var totalCount = 0; var filter = filters.Select(f => FilterConverter.Convert(f)).ToList(); var func = ExpressionBuilder.GetExpression <Data.SystemRole>(filter, (Kapsch.Core.Filters.FilterJoin)filterJoin); var query = includeFunctions ? dbContext.SystemRoles.Include(f => f.SystemRoleFunctions).AsNoTracking() : dbContext.SystemRoles.AsNoTracking(); if (func != null) { query = query.Where(func); } var orderedQuery = asc ? query.OrderByMember(PropertyHelper.GetSortingValue <SystemRoleModel>(orderPropertyName)) : query.OrderByMemberDescending(PropertyHelper.GetSortingValue <SystemRoleModel>(orderPropertyName)); var resultsToSkip = (pageIndex - 1) * pageSize; var pageResults = orderedQuery .Skip(resultsToSkip) .Take(pageSize) .GroupBy(f => new { Total = query.Count() }) .FirstOrDefault(); var entities = new List <SystemRole>(); if (pageResults != null) { totalCount = pageResults.Key.Total; entities = pageResults.ToList(); } var paginationList = new PaginationListModel <SystemRoleModel>(); paginationList.PageIndex = pageIndex; paginationList.PageSize = pageSize; paginationList.Models = entities.Select(f => new SystemRoleModel { ID = f.ID, Name = f.Name, Description = f.Description, SystemFunctions = includeFunctions ? f.SystemRoleFunctions.Select(g => new SystemFunctionModel { ID = g.SystemFunction.ID, Name = g.SystemFunction.Name, Description = g.SystemFunction.Description }) .ToList() : null }) .ToList(); paginationList.TotalCount = totalCount; return(Ok(paginationList)); } }
public IHttpActionResult GetCourtPaginatedList([FromBody] IList <FilterModel> filters, Kapsch.Gateway.Models.Shared.Enums.FilterJoin filterJoin, bool asc, string orderPropertyName, int pageIndex, int pageSize) { using (var dbContext = new DataContext()) { var totalCount = 0; var filter = filters.Select(f => FilterConverter.Convert(f)).ToList(); var func = ExpressionBuilder.GetExpression <Data.Court>(filter, (Kapsch.Core.Filters.FilterJoin)filterJoin); var query = dbContext .Courts .Include(f => f.AddressInfo) .AsNoTracking(); if (func != null) { query = query.Where(func); } var orderedQuery = asc ? query.OrderByMember(PropertyHelper.GetSortingValue <CourtModel>(orderPropertyName)) : query.OrderByMemberDescending(PropertyHelper.GetSortingValue <CourtModel>(orderPropertyName)); var resultsToSkip = (pageIndex - 1) * pageSize; var pageResults = orderedQuery .Skip(resultsToSkip) .Take(pageSize) .GroupBy(f => new { Total = query.Count() }) .FirstOrDefault(); var entities = new List <Court>(); if (pageResults != null) { totalCount = pageResults.Key.Total; entities = pageResults.ToList(); } var paginationList = new PaginationListModel <CourtModel>(); paginationList.PageIndex = pageIndex; paginationList.PageSize = pageSize; paginationList.Models = entities.Select(f => new CourtModel { ID = f.ID, CourtName = f.CourtName, CourtTime = f.CourtTime, PersonInfoID = f.PersonInfoID, ContemptAmount = f.ContemptAmount, ContemptDays = f.ContemptDays, BankingInfoID = f.BankingInfoID, DistrictID = f.DistrictID, CasePost = f.CasePost, CasePre = f.CasePre, SequenceName = f.SequenceName, Status = (Models.Enums.Status)f.Status, WarrantExpireDays = f.WarrantExpireDays, WarrantLetterGrace = f.WarrantLetterGrace, WarrantPost = f.WarrantPost, WarrantPre = f.WarrantPre, CaptureDate = f.CaptureDate, DaysToCourtDate = f.DaysToCourtDate, OverAllocation = f.OverAllocation, ReIssueInvalidServing = f.ReIssueInvalidServing, SummonsExpireDays = f.SummonsExpireDays, TypeOfServiceAllowed = f.TypeOfServiceAllowed, UserId = f.CredentialID, Address = f.AddressInfo == null ? null : new AddressInfoModel { ID = f.AddressInfo.ID, AddressTypeID = (long)f.AddressInfo.AddressTypeID, SourceID = f.AddressInfo.SourceID, PersonInfoID = f.AddressInfo.PersonInfoID, Line1 = f.AddressInfo.Line1, Line2 = f.AddressInfo.Line2, Suburb = f.AddressInfo.Suburb, Town = f.AddressInfo.Town, Country = f.AddressInfo.Country, Code = f.AddressInfo.Code, CreatedDate = f.AddressInfo.CreatedDate, CreatedUserDetailID = f.AddressInfo.CreatedCredentialID, IsPrefferedIndicator = f.AddressInfo.IsPrefferedIndicator, Latitude = f.AddressInfo.Latitude, Longitude = f.AddressInfo.Longitude } }) .ToList(); paginationList.TotalCount = totalCount; return(Ok(paginationList)); } }
public IHttpActionResult GetCameraPaginatedList([FromBody] IList <FilterModel> filters, Kapsch.Gateway.Models.Shared.Enums.FilterJoin filterJoin, bool asc, string orderPropertyName, int pageIndex, int pageSize) { using (var dbContext = new DataContext()) { var totalCount = 0; var filter = filters.Select(f => FilterConverter.Convert(f)).ToList(); var func = ExpressionBuilder.GetExpression <Data.Camera>(filter, (Kapsch.Core.Filters.FilterJoin)filterJoin); var query = dbContext .Cameras .AsNoTracking(); if (func != null) { query = query.Where(func); } var orderedQuery = asc ? query.OrderByMember(PropertyHelper.GetSortingValue <CameraModel>(orderPropertyName)) : query.OrderByMemberDescending(PropertyHelper.GetSortingValue <CameraModel>(orderPropertyName)); var resultsToSkip = (pageIndex - 1) * pageSize; var pageResults = orderedQuery .Skip(resultsToSkip) .Take(pageSize) .GroupBy(f => new { Total = query.Count() }) .FirstOrDefault(); var entities = new List <Camera>(); if (pageResults != null) { totalCount = pageResults.Key.Total; entities = pageResults.ToList(); } var paginationList = new PaginationListModel <CameraModel>(); paginationList.PageIndex = pageIndex; paginationList.PageSize = pageSize; paginationList.Models = entities.Select(f => new CameraModel { ID = f.ID, AdapterType = (Models.Enums.CameraAdapterType)f.CameraAdapterType, ConfigJson = f.ConfigJson, CreatedTimeStamp = f.CreatedTimeStamp, ConnectToHost = f.ConnectToHost == "1", DeviceConnectionType = (Models.Enums.CameraConnectionType)f.CameraConnectionType, DeviceStatus = (Models.Enums.CameraStatusType)f.CameraStatusType, FriendlyName = f.FriendlyName, GpsLatitude = f.GpsLatitude, GpsLongitude = f.GpsLongitude, IsEnabled = f.IsEnabled == "1", ModifiedTimeStamp = f.ModifiedTimeStamp }) .ToList(); paginationList.TotalCount = totalCount; return(Ok(paginationList)); } }
public IHttpActionResult GetDistrictPaginatedList([FromBody] IList <FilterModel> filters, Kapsch.Gateway.Models.Shared.Enums.FilterJoin filterJoin, bool asc, string orderPropertyName, int pageIndex, int pageSize) { using (var dbContext = new DataContext()) { var totalCount = 0; var filter = filters.Select(f => FilterConverter.Convert(f)).ToList(); var func = ExpressionBuilder.GetExpression <Data.District>(filter, (Kapsch.Core.Filters.FilterJoin)filterJoin); var query = dbContext .Districts .AsNoTracking(); if (func != null) { query = query.Where(func); } var orderedQuery = asc ? query.OrderByMember(PropertyHelper.GetSortingValue <DistrictModel>(orderPropertyName)) : query.OrderByMemberDescending(PropertyHelper.GetSortingValue <DistrictModel>(orderPropertyName)); var resultsToSkip = (pageIndex - 1) * pageSize; var pageResults = orderedQuery .Skip(resultsToSkip) .Take(pageSize) .GroupBy(f => new { Total = query.Count() }) .FirstOrDefault(); var entities = new List <District>(); if (pageResults != null) { totalCount = pageResults.Key.Total; entities = pageResults.ToList(); } var paginationList = new PaginationListModel <DistrictModel>(); paginationList.PageIndex = pageIndex; paginationList.PageSize = pageSize; paginationList.Models = entities.Select(f => new DistrictModel { ID = f.ID, Province = f.Province, Town = f.Town, Suburb = f.Suburb, Street = f.Street, Code = f.Code, POBox = f.POBox, PostalCode = f.PostalCode, PostalStreet = f.PostalStreet, PostalSuburb = f.PostalSuburb, PostalTown = f.PostalTown, TicketPre = f.TicketPre, TicketPost = f.TicketPost, TicketSequenceName = f.TicketSequenceName, CaseSequenceName = f.CaseSequenceName, Section56TicketPre = f.Section56TicketPre, Section56TicketPost = f.Section56TicketPost, TrafficTicketPre = f.TrafficTicketPre, TrafficTicketPost = f.TrafficTicketPost, DepartmantName = f.DepartmantName, Telephone = f.Telephone, Faks = f.Faks, CaseNoPre = f.CaseNoPre, CaseNoPost = f.CaseNoPost, DistrictAll = f.DistrictAll, RegionID = f.RegionID, DistrictTypeID = f.DistrictTypeID, AccountNo = f.AccountNo, Bank = f.Bank, Branch = f.Branch, BranchCode = f.BranchCode, AccountType = f.AccountType, BankDetails = f.BankDetails, ExtTicketPost = f.ExtTicketPost, IACode = f.IACode, NatisNumber = f.NatisNumber, NatisSequenceName = f.NatisSequenceName, OfficeHours = f.OfficeHours, Sectiontion67Pre = f.Sectiontion67Pre, Section67Post = f.Section67Post, J175Printing = f.J175Printing, CentralCaptureIndicator = f.CentralCaptureIndicator, ActiveIndicator = f.ActiveIndicator, EmailAddress = f.EmailAddress, ITicketPre56 = f.ITicketPre56, ITicketSeqName56 = f.ITicketSeqName56, ITicketPre341 = f.ITicketPre341, ITicketSeqName341 = f.ITicketSeqName341, BranchName = f.BranchName, SiteLogo = f.SiteLogo, PaymentOptions = f.PaymentOptions }) .ToList(); paginationList.TotalCount = totalCount; return(Ok(paginationList)); } }
public IHttpActionResult GetInfringementLocationPaginatedList([FromBody] IList <FilterModel> filters, Kapsch.Gateway.Models.Shared.Enums.FilterJoin filterJoin, bool asc, string orderPropertyName, int pageIndex, int pageSize) { using (var dbContext = new DataContext()) { var totalCount = 0; var filter = filters.Select(f => FilterConverter.Convert(f)).ToList(); var func = ExpressionBuilder.GetExpression <Data.InfringementLocation>(filter, (Kapsch.Core.Filters.FilterJoin)filterJoin); var query = dbContext .InfringementLocations .Include(f => f.Court) .AsNoTracking(); if (func != null) { query = query.Where(func); } var orderedQuery = asc ? query.OrderByMember(PropertyHelper.GetSortingValue <InfringementLocationModel>(orderPropertyName)) : query.OrderByMemberDescending(PropertyHelper.GetSortingValue <InfringementLocationModel>(orderPropertyName)); var resultsToSkip = (pageIndex - 1) * pageSize; var pageResults = orderedQuery .Skip(resultsToSkip) .Take(pageSize) .GroupBy(f => new { Total = query.Count() }) .FirstOrDefault(); var entities = new List <InfringementLocation>(); if (pageResults != null) { totalCount = pageResults.Key.Total; entities = pageResults.ToList(); } var paginationList = new PaginationListModel <InfringementLocationModel>(); paginationList.PageIndex = pageIndex; paginationList.PageSize = pageSize; paginationList.Models = entities.Select(f => new InfringementLocationModel { ID = f.ID, Code = f.Code, Description = f.Description, CourtID = f.CourtID, CourtName = f.Court == null ? string.Empty : f.Court.CourtName, GpsLatitude = f.GpsLatitude, GpsLongitude = f.GpsLongitude, InfringementLocationType = (Models.Enums.InfringementLocationType)f.InfringementLocationType }) .ToList(); paginationList.TotalCount = totalCount; return(Ok(paginationList)); } }