// POST: api/Copier
        public IHttpActionResult Post([FromBody]Copier copier)
        {
            OperationResult operationResult = new Models.OperationResult();
            CopierData copierData = new CopierData();


            if (copier.ID == 0)
            {
                operationResult = copierData.AddCopier(copier);
                if (operationResult.Success)
                {
                    return Ok();
                }
                else
                {
                    return BadRequest(operationResult.ErrorMessage);
                }
            }
            else
            {
                operationResult = copierData.UpdateCopier(copier);
                if (operationResult.Success)
                {
                    return Ok();
                }
                else
                {
                    return BadRequest(operationResult.ErrorMessage);
                }
            }
        }
        // GET: api/ReviewDocuments/5
        public IEnumerable<ReviewScannedDocuments> Get(string id)
        {
            CopierData copierData = new CopierData();

            if (id != "None")
            {
                copierData.UpdateCurrentCopier(id);
            }
            List<ReviewScannedDocuments> reviewScannedDocumentsList = new List<ReviewScannedDocuments>();
            reviewScannedDocumentsList = CreateDocumentList(id);
            return reviewScannedDocumentsList;
        }
        private List<ReviewScannedDocuments> CreateDocumentList(string id)
        {
            DocumentsData documentsData = new DocumentsData();
            CopierData copierData = new CopierData();
            string serialNumber = copierData.GetSerialNumber(id);
            //string serialNumber = string.Empty;

            ReviewScannedDocuments reviewScannedDocuments = new Models.ReviewScannedDocuments();
            List<ReviewScannedDocuments> reviewScannedDocumentsList = new List<ReviewScannedDocuments>();

            try
            {
                DirectoryInfo directory = new DirectoryInfo(ConfigurationValues.ReviewDocumentPath);
                FileInfo[] files = directory.GetFiles("*.pdf");
                foreach (FileInfo file in files)
                {
                    string[] copierLocation = file.Name.Split('_');
                    if (copierLocation[0] == serialNumber)
                    {
                        reviewScannedDocuments = new Models.ReviewScannedDocuments();
                        reviewScannedDocuments.CreationDate = file.CreationTime.ToShortDateString()
                            + " " + file.CreationTime.ToShortTimeString();
                        reviewScannedDocuments.DocumentName = file.Name;
                        reviewScannedDocuments.PageCount = Walden.Medical.Library.Pdf.GetPDFPageCount(file.FullName);
                        reviewScannedDocuments.DocumentPath = ConfigurationValues.PdfFolder + file.Name;
                        reviewScannedDocuments.CopierLocation = copierData.GetCopierLocationName(copierLocation[0]);
                        reviewScannedDocumentsList.Add(reviewScannedDocuments);
                    }
                }

                List<ReviewScannedDocuments> reviewScannedDocumentsList2 = documentsData.GetArchiveDocumentList(id);

                for (int i = 0; i < reviewScannedDocumentsList2.Count; i++)
                {
                    reviewScannedDocumentsList.Add(reviewScannedDocumentsList2[i]);
                }

                return reviewScannedDocumentsList;
            }
            catch (Exception er)
            {
                string s1 = er.ToString();
                return reviewScannedDocumentsList;
            }
        }
        // PUT: api/TagDocument/5
        public IHttpActionResult Put(string id)
        {
            OperationResult operationResult = new OperationResult();
            OperationResult getDocumentArchiveID = new OperationResult();

            DocumentsData documentsData = new DocumentsData();
            CopierData copierData = new CopierData();

            File.Copy(ConfigurationValues.ReviewDocumentPath + id
                , ConfigurationValues.PathToArchiveFolder + id, true);

            File.Copy(ConfigurationValues.ReviewDocumentPath + id
                , ConfigurationValues.ProcessDocumentPath + id, true);

            File.Delete(ConfigurationValues.ReviewDocumentPath + id);

            //CopierData Location
            //PageCount
            //CreationDate
            ReviewScannedDocuments reviewScannedDocuments = new ReviewScannedDocuments();
            //reviewScannedDocuments.CopierLocation = 
            string[] copierLocation = id.Split('_');

            reviewScannedDocuments = new Models.ReviewScannedDocuments();

            FileInfo fileInfo = new FileInfo(ConfigurationValues.ProcessDocumentPath + id);

            //FileAttributes fileAttributes = File.GetAttributes(ConfigurationValues.ProcessDocumentPath + id);

            reviewScannedDocuments.CreationDate = fileInfo.CreationTime.ToShortDateString()
                + " " + fileInfo.CreationTime.ToShortTimeString();
            reviewScannedDocuments.DocumentName = fileInfo.Name;
            reviewScannedDocuments.PageCount = Walden.Medical.Library.Pdf.GetPDFPageCount(ConfigurationValues.ProcessDocumentPath + id);
            reviewScannedDocuments.DocumentPath = ConfigurationValues.PdfFolder + fileInfo.Name;
            reviewScannedDocuments.CopierLocation = copierData.GetCopierLocationName(copierLocation[0]);

            OperationResult operationResult2 = ValidatePageCounts(ConfigurationValues.ProcessDocumentPath + id);

            if (operationResult2.Success != true)
            {

                getDocumentArchiveID = documentsData.ArchiveScannedDocument(reviewScannedDocuments, "F", operationResult2.ErrorMessage);

                File.Copy(ConfigurationValues.ProcessDocumentPath + id,
                    ConfigurationValues.PathToViewErrorFolder + id, true);

                File.Delete(ConfigurationValues.ProcessDocumentPath + id);

                return BadRequest("Please review your documents and try again");
            }

            getDocumentArchiveID = documentsData.ArchiveScannedDocument(reviewScannedDocuments, "T", operationResult2.ErrorMessage);

            documentArchiveID = int.Parse(getDocumentArchiveID.MessageList[0]);

            System.Timers.Timer timer = new System.Timers.Timer();
            timer.Interval = (3000);
            timer.Elapsed += (sender, e) => { HandleTimerElapsed(barCodeText, documentArchiveID); };
            timer.Enabled = true;
            timer.AutoReset = false;

            return Ok();
        }
        // DELETE: api/Copier/5
        public IHttpActionResult Delete([FromBody] Copier copier)
        {
            OperationResult operationResult = new Models.OperationResult();
            CopierData copierData = new CopierData();

            operationResult = copierData.DeleteCopier(copier);
            if (operationResult.Success)
            {
                return Ok();
            }
            else
            {
                return BadRequest(operationResult.ErrorMessage);
            }
        }
 // GET: api/Copier
 public IEnumerable<Copier> Get()
 {
     CopierData copierData = new CopierData();
     return copierData.GetCopierList();
 }
 // GET: api/CurrentCopier
 public string Get()
 {
     CopierData copierData = new CopierData();
     return copierData.GetCurrentCopierByUser(Utility.GetUserName());
 }