예제 #1
0
        public async Task AddToPrintQueue(int[] licenseIds, long userId)
        {
            //TODO put all context saves in AppService layer to optimize.  This method just simply use "AddToPrintQueue(int, long)" method
            if (await _printQueueRepo.GetPrintQueueCount(userId) >= 120)
            {
                throw new System.ApplicationException("Max number of licenses in print queue");
            }

            foreach (int licenseId in licenseIds)
            {
                if (!await _licenseRepo.ContainsId(licenseId))
                {
                    throw new System.ArgumentException("Invalid Argument", string.Empty);
                }

                var printQueueEntry = new PrintQueue(userId, licenseId);
                if (!printQueueEntry.IsValid())
                {
                    throw new System.ArgumentException("Invalid Argument", string.Empty);
                }

                await _printQueueRepo.Insert(printQueueEntry);
            }

            await _printQueueRepo.SaveAsync();
        }
예제 #2
0
        public async Task AddToPrintQueue(int licenseId, long userId)
        {
            if (!await _licenseRepo.ContainsId(licenseId))
            {
                throw new System.ArgumentException("Invalid Argument", string.Empty);
            }

            if (await _printQueueRepo.GetPrintQueueCount(userId) >= 120)
            {
                throw new System.ApplicationException("Max number of licenses in print queue");
            }

            var printQueueEntry = new PrintQueue(userId, licenseId);

            if (!printQueueEntry.IsValid())
            {
                throw new System.ArgumentException("Invalid Argument", string.Empty);
            }

            await _printQueueRepo.Insert(printQueueEntry);

            await _printQueueRepo.SaveAsync();
        }