/// <summary> /// Get List of Things. /// </summary> /// <param name="searchFor">Search text as per the 'Title' field.</param> /// <param name="locationID">Filter by Location ID. You can keep it null or empty to ignore this filter.</param> /// <param name="pageNumber">Page Number.</param> /// <param name="pageSize">Items count per page.</param> /// <param name="loadParents">Enable or Disable loading the Parents objects.</param> /// <param name="loadChilds">Enable or Disable loading the Childs objects.</param> /// <returns></returns> public APIThingResponseModels.GetThingsList GetThingsList(string searchFor, long?locationID, bool loadThingEnds, bool loadEndpoints, bool loadLocation, bool loadThingExtensionValues, int pageNumber, int pageSize) { APIThingResponseModels.GetThingsList result = new APIThingResponseModels.GetThingsList(); IPagedList <Thing> thingsPL = uof_Repositories.repoThings.GetPagedList(searchFor, locationID, pageNumber, pageSize); List <Thing> things = thingsPL.ToList(); List <APIThing> listAPIThings = new List <APIThing>(); foreach (Thing thing in things) { APIThing apiThing = TypesMapper.APIThingAdapter.fromThing(thing, loadLocation, loadThingEnds, loadThingEnds, loadThingExtensionValues); listAPIThings.Add(apiThing); } result.Things = listAPIThings; PagingInfoResponseModel pagingInfo = new PagingInfoResponseModel(); pagingInfo.CurrentPage = thingsPL.PageNumber; pagingInfo.ItemsPerPage = thingsPL.PageSize; pagingInfo.ItemsCount = thingsPL.TotalItemCount; pagingInfo.PagesCount = thingsPL.PageCount; result.PagingInfo = pagingInfo; return(result); }
/// <summary> /// Get List of LocationViews. /// </summary> /// <param name="pageNumber">Page Number.</param> /// <param name="pageSize">Items count per page.</param> /// <param name="loadParents">Enable or Disable loading the Parents objects.</param> /// <param name="loadChilds">Enable or Disable loading the Childs objects.</param> /// <param name="searchFor">Search text as per the 'Title' field.</param> /// <returns>Get List of LocationViews.</returns> public APILocationViewResponseModels.GetLocationViewsList GetLocationViewsList(string searchFor, bool loadLocations, int pageNumber, int pageSize) { APILocationViewResponseModels.GetLocationViewsList result = new APILocationViewResponseModels.GetLocationViewsList(); IPagedList <LocationView> locationViewsPL = uof_Repositories.repoLocationViews.GetPagedList(searchFor, pageNumber, pageSize); List <LocationView> locationViews = locationViewsPL.ToList(); List <APILocationView> listAPILocationViews = new List <APILocationView>(); foreach (LocationView locationView in locationViews) { APILocationView apiLocationView = TypesMapper.APILocationViewAdapter.fromLocationView(locationView, loadLocations); listAPILocationViews.Add(apiLocationView); } result.Views = listAPILocationViews; PagingInfoResponseModel pagingInfo = new PagingInfoResponseModel(); pagingInfo.CurrentPage = locationViewsPL.PageNumber; pagingInfo.ItemsPerPage = locationViewsPL.PageSize; pagingInfo.ItemsCount = locationViewsPL.TotalItemCount; pagingInfo.PagesCount = locationViewsPL.PageCount; result.PagingInfo = pagingInfo; return(result); }
/// <summary> /// Get Locations list that have warnings Only. /// </summary> /// <param name="pageNumber">Page Number.</param> /// <param name="pageSize">Items count per page.</param> /// <param name="loadParents">Enable or Disable loading the Parents objects.</param> /// <param name="loadChilds">Enable or Disable loading the Childs objects.</param> /// <param name="viewID">The requested View to validate it's own locations for a warnings</param> /// <returns>List of Locations that have one warning or more.</returns> public APILocationResponseModels.GetLocationsList GetLocationsWithWarningsList(string searchFor, long?viewID, bool loadViews, bool loadThings, int pageNumber, int pageSize) { APILocationResponseModels.GetLocationsList result = new APILocationResponseModels.GetLocationsList(); IPagedList <Location> locationsPL = uof_Repositories.repoLocations.GetLocationsWithWarningsPagedList(searchFor, viewID, pageNumber, pageSize); List <Location> locations = locationsPL.ToList(); List <APILocation> listAPILocations = new List <APILocation>(); foreach (Location location in locations) { APILocation apiLocation = TypesMapper.APILocationAdapter.fromLocation(location, loadViews, loadThings); listAPILocations.Add(apiLocation); } result.Locations = listAPILocations; PagingInfoResponseModel pagingInfo = new PagingInfoResponseModel(); pagingInfo.CurrentPage = locationsPL.PageNumber; pagingInfo.ItemsPerPage = locationsPL.PageSize; pagingInfo.ItemsCount = locationsPL.TotalItemCount; pagingInfo.PagesCount = locationsPL.PageCount; result.PagingInfo = pagingInfo; return(result); }
/// <summary> /// Get List of ThingEnds. /// </summary> /// <param name="pageNumber">Page Number.</param> /// <param name="pageSize">Items count per page.</param> /// <param name="loadParents">Enable or Disable loading the Parents objects.</param> /// <param name="loadChilds">Enable or Disable loading the Childs objects.</param> /// <param name="searchFor">Search text as per the 'Title' field.</param> /// <param name="locationID">Filter by Location ID. You can keep it null or empty to ignore this filter.</param> /// <param name="thingID">Filter by Thing ID. You can keep it null or empty to ignore this filter.</param> /// <param name="thingCategoryID">Filter by ThingCategory ID. You can keep it null or empty to ignore this filter.</param> /// <param name="endpointTypeID">Filter by EndPointType ID. You can keep it null or empty to ignore this filter.</param> /// <returns></returns> public APIThingEndResponseModels.GetThingEndsList GetThingEndsList(string searchFor, long?locationID, long?thingID, long?thingCategoryID, long?endpointTypeID, bool loadThing, bool loadEndpoint, int pageNumber, int pageSize) { APIThingEndResponseModels.GetThingEndsList result = new APIThingEndResponseModels.GetThingEndsList(); IPagedList <ThingEnd> thingEndsPL = uof_Repositories.repoThingEnds.GetPagedList(searchFor, locationID, thingID, thingCategoryID, endpointTypeID, endpointTypeID, pageNumber, pageSize); List <ThingEnd> thingEnds = thingEndsPL.ToList(); List <APIThingEnd> listAPIThingEnds = new List <APIThingEnd>(); foreach (ThingEnd te in thingEnds) { APIThingEnd apiThingEnd = TypesMapper.APIThingEndAdapter.fromThingEnd(te, loadThing, loadThing); listAPIThingEnds.Add(apiThingEnd); } result.ThingEnds = listAPIThingEnds; PagingInfoResponseModel pagingInfo = new PagingInfoResponseModel(); pagingInfo.CurrentPage = thingEndsPL.PageNumber; pagingInfo.ItemsPerPage = thingEndsPL.PageSize; pagingInfo.ItemsCount = thingEndsPL.TotalItemCount; pagingInfo.PagesCount = thingEndsPL.PageCount; result.PagingInfo = pagingInfo; return(result); }
/// <summary> /// Get List of EndPoint Commands. /// </summary> /// <param name="pageNumber">Page Number.</param> /// <param name="pageSize">Items count per page.</param> /// <param name="loadParents">Enable or Disable loading the Parents objects.</param> /// <param name="loadChilds">Enable or Disable loading the Childs objects.</param> /// <param name="searchFor">Search text as per the 'Title' field.</param> /// <param name="locationID">Filter by Location ID. You can keep it null or empty to ignore this filter.</param> /// <param name="ThingID">Filter by Thing ID. You can keep it null or empty to ignore this filter.</param> /// <param name="EndPointID">Filter by EndPoint ID. You can keep it null or empty to ignore this filter.</param> /// <returns></returns> public APIEndpointCommandResponseModels.GetEndpointCommandsList GetEndpointCommands(string searchFor, long EndPointID, long ThingID, long locationID, bool loadEndpoint, int pageNumber, int pageSize) { APIEndpointCommandResponseModels.GetEndpointCommandsList result = new APIEndpointCommandResponseModels.GetEndpointCommandsList(); IPagedList <EndPointCommand> endpointCommandsPL = uow_Repositories.repoEndPointCommands.GetPagedList(searchFor, EndPointID, ThingID, locationID, pageNumber, pageSize); List <EndPointCommand> endpointCommands = endpointCommandsPL.ToList(); List <APIEndPointCommand> listAPIEndpointCommands = new List <APIEndPointCommand>(); foreach (EndPointCommand cmd in endpointCommands) { APIEndPointCommand apiCMD = TypesMapper.APIEndPointCommandAdapter.fromEndpointCommand(cmd, loadEndpoint); listAPIEndpointCommands.Add(apiCMD); } result.EndpointCommands = listAPIEndpointCommands; PagingInfoResponseModel pagingInfo = new PagingInfoResponseModel(); pagingInfo.CurrentPage = endpointCommandsPL.PageNumber; pagingInfo.ItemsPerPage = endpointCommandsPL.PageSize; pagingInfo.ItemsCount = endpointCommandsPL.TotalItemCount; pagingInfo.PagesCount = endpointCommandsPL.PageCount; result.PagingInfo = pagingInfo; return(result); }
public APIEndpointResponseModels.GetEndpointsList GetEndPointsWithWarnings(string searchFor, long?deviceID, long?thingID, long?locationID, long?viewID, bool loadDevice, bool loadThing, int pageNumber, int pageSize) { APIEndpointResponseModels.GetEndpointsList result = new APIEndpointResponseModels.GetEndpointsList(); IPagedList <Endpoint> endpointsPL = uof_Repositories.repoEndpoints.GetEndpointsWithWarningsPagedList(searchFor, deviceID, thingID, locationID, viewID, pageNumber, pageSize); List <Endpoint> endpoints = endpointsPL.ToList(); List <APIEndPoint> listAPIEndpoints = new List <APIEndPoint>(); foreach (Endpoint end in endpoints) { APIEndPoint apiEnd = TypesMapper.APIEndPointAdapter.fromEndpoint(end, loadDevice, loadThing); listAPIEndpoints.Add(apiEnd); } result.Endpoints = listAPIEndpoints; PagingInfoResponseModel pagingInfo = new PagingInfoResponseModel(); pagingInfo.CurrentPage = endpointsPL.PageNumber; pagingInfo.ItemsPerPage = endpointsPL.PageSize; pagingInfo.ItemsCount = endpointsPL.TotalItemCount; pagingInfo.PagesCount = endpointsPL.PageCount; result.PagingInfo = pagingInfo; return(result); }
/// <summary> /// Get List of Devices. /// </summary> /// <param name="pageNumber">Page Number.</param> /// <param name="pageSize">Items count per page.</param> /// <param name="loadParents">Enable or Disable loading the Parents objects.</param> /// <param name="loadChilds">Enable or Disable loading the Childs objects.</param> /// <param name="searchFor">Search text as per the 'Title' field.</param> /// <returns></returns> public APIDeviceResponseModels.GetDevicesList GetDevices(string searchFor, long locationID, bool loadEndpoints, bool loadDeviceCommands, int pageNumber, int pageSize) { APIDeviceResponseModels.GetDevicesList result = new APIDeviceResponseModels.GetDevicesList(); uow_Repositories.repoDevices.GetPagedList(searchFor, locationID, pageNumber, pageSize); List <APIDevice> devicesList = new List <APIDevice>(); IPagedList <Device> devicesPagedList = db.Devices.Include("DeviceStatu").Include("DeviceCommands") .Where(v => searchFor == null || v.Title.Contains(searchFor)).ToList().ToPagedList(pageNumber, pageSize); foreach (Device item in devicesPagedList) { APIDevice apiDevice = TypesMapper.APIDeviceAdapter.fromDevice(item, loadEndpoints, loadDeviceCommands); devicesList.Add(apiDevice); } result.Devices = devicesList; PagingInfoResponseModel pagingInfo = new PagingInfoResponseModel(); pagingInfo.CurrentPage = devicesPagedList.PageNumber; pagingInfo.ItemsPerPage = devicesPagedList.PageSize; pagingInfo.ItemsCount = devicesPagedList.TotalItemCount; pagingInfo.PagesCount = devicesPagedList.PageCount; result.PagingInfo = pagingInfo; return(result); }
/// <summary> /// Get list of Device's commands. /// </summary> /// <param name="pageNumber">Page Number.</param> /// <param name="pageSize">Items count per page.</param> /// <param name="loadParents">Enable or Disable loading the Parents objects.</param> /// <param name="loadChilds">Enable or Disable loading the Childs objects.</param> /// <param name="searchFor">Search text as per the 'Title' field.</param> /// <param name="locationID">Filter by Location ID. You can keep it null or empty to ignore this filter.</param> /// <param name="DeviceID">Filter by Device ID. You can keep it null or empty to ignore this filter.</param> /// <returns></returns> public APIDeviceCommandResponseModels.GetDeviceCommandsList GetDeviceCommandsList(string searchFor, long locationID, long DeviceID, bool loadDevice, int pageNumber, int pageSize) { APIDeviceCommandResponseModels.GetDeviceCommandsList result = new APIDeviceCommandResponseModels.GetDeviceCommandsList(); IPagedList <DeviceCommand> cmdsPL = uow_Repositories.repoDeviceCommands.GetPagedList(searchFor, DeviceID, locationID, pageNumber, pageSize); List <DeviceCommand> cmds = cmdsPL.ToList(); List <APIDeviceCommand> apiCmds = new List <APIDeviceCommand>(); foreach (DeviceCommand cmd in cmds) { APIDeviceCommand apiCmd = TypesMapper.APIDeviceCommandAdapter.fromDeviceCommand(cmd, loadDevice); apiCmds.Add(apiCmd); } result.DeviceCommands = apiCmds; PagingInfoResponseModel pagingInfo = new PagingInfoResponseModel(); pagingInfo.CurrentPage = cmdsPL.PageNumber; pagingInfo.ItemsPerPage = cmdsPL.PageSize; pagingInfo.ItemsCount = cmdsPL.TotalItemCount; pagingInfo.PagesCount = cmdsPL.PageCount; result.PagingInfo = pagingInfo; return(result); }