Example #1
0
        public async Task <APIDeviceResponseModels.GetDevicesList> GetDevicesListAsync(APIDeviceRequestModels.GetDevicesList rm)
        {
            string strResult = await HttpPost("/api/Devices/GetDevicesList", JsonConvert.SerializeObject(rm));

            APIDeviceResponseModels.GetDevicesList result = (APIDeviceResponseModels.GetDevicesList)JsonConvert.DeserializeObject(strResult, typeof(APIDeviceResponseModels.GetDevicesList));
            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);
        }
Example #3
0
        private async void btnGetDevices_ClickAsync(object sender, EventArgs e)
        {
            Initialize();

            APIDeviceRequestModels.GetDevicesList model = new APIDeviceRequestModels.GetDevicesList();
            model.LoadDeviceCommands = true;
            model.LoadEndpoints      = true;

            model.PageNumber = 1; model.PageSize = 1; model.Token = Guid.Parse(txtToken.Text);

            APIDeviceResponseModels.GetDevicesList devs = await uow.DevicesService.GetDevicesListAsync(model);

            gv1.DataSource = devs.Devices;
        }