Beispiel #1
0
        /// <summary>
        /// Adds a printer
        /// </summary>
        /// <param name="printerRequest"></param>
        /// <param name="facilityKey"></param>
        /// <returns></returns>
        public async Task AddPrinter(PrinterRequest printerRequest, Guid facilityKey)
        {
            var printerModel = await _printerModelRepository.GetAsync(printerRequest.PrinterModelKey);

            if (printerModel == null)
            {
                throw new InvalidPrinterException(Resource.ResourceManager.GetString($"E{ErrorCode.InvalidInput}"), ErrorCode.InvalidInput);
            }

            var printer = _mapper.Map <Models.Data.Printer>(printerRequest);
            var Id      = Guid.NewGuid();

            printer.PrinterKey  = Id;
            printer.FacilityKey = facilityKey;
            await _printerRepository.AddAsync(printer);

            _unitOfWork.CommitChanges();
        }