private SingleEntityDataServiceResponse <HardwareProfile> GetHardwareProfile(GetHardwareProfileDataRequest request)
            {
                ThrowIf.Null(request, "request");
                ThrowIf.Null(request.QueryResultSettings, "request.QueryResultSettings");
                ThrowIf.NullOrWhiteSpace(request.ProfileId, "request.ProfileId");

                var query = new SqlPagedQuery(request.QueryResultSettings)
                {
                    From = HardwareProfilesViewName
                };

                // Add query clause for profile id
                query.IsQueryByPrimaryKey = true;

                query.Where = @"(PROFILEID = @ProfileId)";
                query.Parameters["@ProfileId"] = request.ProfileId;

                // Load hardware profile
                HardwareProfile hardwareProfile;

                using (DatabaseContext databaseContext = new DatabaseContext(request.RequestContext))
                {
                    hardwareProfile = databaseContext.ReadEntity <HardwareProfile>(query).SingleOrDefault();
                }

                if (hardwareProfile != null)
                {
                    GetHardwareProfileCashDrawersDataRequest getCashDrawersDataRequest  = new GetHardwareProfileCashDrawersDataRequest(request.ProfileId, null, QueryResultSettings.AllRecords);
                    PagedResult <HardwareProfileCashDrawer>  hardwareProfileCashDrawers = request.RequestContext.Execute <EntityDataServiceResponse <HardwareProfileCashDrawer> >(getCashDrawersDataRequest).PagedEntityCollection;
                    hardwareProfile.SetupDevices(
                        this.GetHardwareProfilePrinters(request.ProfileId, request.RequestContext).Results,
                        this.GetHardwareProfileScanners(request.ProfileId, request.RequestContext).Results,
                        hardwareProfileCashDrawers.Results);
                }

                return(new SingleEntityDataServiceResponse <HardwareProfile>(hardwareProfile));
            }
            private EntityDataServiceResponse <HardwareProfileCashDrawer> GetHardwareProfileCashDrawers(GetHardwareProfileCashDrawersDataRequest request)
            {
                ThrowIf.Null(request, "request");
                ThrowIf.Null(request.QueryResultSettings, "request.QueryResultSettings");

                if (string.IsNullOrWhiteSpace(request.ProfileId) && string.IsNullOrWhiteSpace(request.TerminalId))
                {
                    throw new ArgumentException("Either profileId or TerminalId should be provided.");
                }

                var query = new SqlPagedQuery(request.QueryResultSettings)
                {
                    IsQueryByPrimaryKey = false
                };

                if (!string.IsNullOrWhiteSpace(request.ProfileId))
                {
                    query.From = HardwareProfileCashDrawersViewName;

                    // Add query clause for profile id
                    query.Where = @"(PROFILEID = @ProfileId)";
                    query.Parameters["@ProfileId"] = request.ProfileId;
                }
                else if (!string.IsNullOrWhiteSpace(request.TerminalId))
                {
                    query.From = TerminalCashDrawersViewName;

                    // Add query clause for profile id
                    query.Where = @"(TERMINALID = @TerminalId)";
                    query.Parameters["@TerminalId"] = request.TerminalId;
                }

                PagedResult <HardwareProfileCashDrawer> hardwareProfileCashDrawers;

                using (DatabaseContext databaseContext = new DatabaseContext(request.RequestContext))
                {
                    hardwareProfileCashDrawers = databaseContext.ReadEntity <HardwareProfileCashDrawer>(query);
                }

                return(new EntityDataServiceResponse <HardwareProfileCashDrawer>(hardwareProfileCashDrawers));
            }