Example #1
0
        public static string convertSerializedJSON(SDDocumentation doc)
        {
            sdDocJSON docJSON = new sdDocJSON();

            docJSON.id            = doc.id;
            docJSON.index         = DocumentList.IndexOf(doc);
            docJSON.alias         = doc.alias;
            docJSON.documentTitle = doc.documentTitle;
            if (doc.DocumentLink_id != null)
            {
                using (var curDB = new HelpDesk_DB())
                {
                    DocumentLink pdfDoc = curDB.DocumentLinks.SingleOrDefault(p => p.Id == doc.DocumentLink_id);
                    docJSON.documentLink = pdfDoc.link;
                    docJSON.PDFaccess    = pdfDoc.Access_id;
                }
            }
            docJSON.passwordTitle = doc.passwordTitle;
            if (doc.PasswordHyperlink_id != null)
            {
                using (var curDB = new HelpDesk_DB())
                {
                    DocumentLink pwDoc = curDB.DocumentLinks.SingleOrDefault(p => p.Id == doc.PasswordHyperlink_id);
                    docJSON.passwordHyperlink = pwDoc.link;
                    docJSON.PWaccess          = pwDoc.Access_id;
                }
            }

            var json = new JavaScriptSerializer().Serialize(docJSON);

            return(json);
        }
Example #2
0
        public static void submit(sdDocJSON doc)
        {
            DocumentLink pdfLink = new DocumentLink();

            pdfLink.link      = doc.documentLink;
            pdfLink.Access_id = doc.PDFaccess;

            DocumentLink pwLink = new DocumentLink();

            pwLink.link      = doc.passwordHyperlink;
            pwLink.Access_id = doc.PWaccess;

            SDDocumentation sdDoc = new SDDocumentation();

            sdDoc.alias     = doc.alias;
            sdDoc.Status_id = 2;

            //TODO: Change if this Learning Center option is added to the info gathering page
            sdDoc.LearningCenterCategory_id = 1;

            sdDoc.documentTitle = doc.documentTitle;
            //Check for null document links
            //TODO: You can fix this so that null are handled in addDocumentLink Method
            if (doc.documentLink != "")
            {
                sdDoc.DocumentLink_id = addDocumentLink(pdfLink);
            }

            sdDoc.passwordTitle = doc.passwordTitle;

            //check for null pw links
            if (doc.passwordHyperlink != "")
            {
                sdDoc.PasswordHyperlink_id = addDocumentLink(pwLink);
            }

            addSDDocumentation(sdDoc);

            log();
        }
Example #3
0
        public static void updateDoc(sdDocJSON doc)
        {
            SDDocumentation newSDDoc = new SDDocumentation();

            newSDDoc.Status_id = 2;

            using (var curDB = new HelpDesk_DB())
            {
                SDDocumentation oldDoc      = DocumentList[doc.index];
                var             originalDoc = curDB.SDDocumentations.Find(oldDoc.id);
                originalDoc.Status_id = 4;  //Historic

                //Transfer persisting information to new document
                newSDDoc.LearningCenterCategory_id = oldDoc.LearningCenterCategory_id;
                newSDDoc.Original_id = oldDoc.Original_id;
                if (oldDoc.learningCenterOrder != null)
                {
                    newSDDoc.learningCenterOrder = oldDoc.learningCenterOrder;
                }

                curDB.SaveChanges();
                //Rebuilds document list for find reference
                DocumentList = curDB.SDDocumentations.Where(p => p.Status_id == 2).OrderBy(p => p.alias).ToList();
            }

            DocumentLink pdfLink = new DocumentLink();

            pdfLink.link      = doc.documentLink;
            pdfLink.Access_id = doc.PDFaccess;

            //Check for null document links
            if (doc.documentLink != "")
            {
                newSDDoc.DocumentLink_id = addDocumentLink(pdfLink);
            }

            DocumentLink pwLink = new DocumentLink();

            pwLink.link      = doc.passwordHyperlink;
            pwLink.Access_id = doc.PWaccess;
            //check for null pw links
            if (doc.passwordHyperlink != "")
            {
                newSDDoc.PasswordHyperlink_id = addDocumentLink(pwLink);
            }

            newSDDoc.alias = doc.alias;

            newSDDoc.documentTitle = doc.documentTitle;


            newSDDoc.passwordTitle = doc.passwordTitle;


            using (var curDB = new HelpDesk_DB())
            {
                curDB.SDDocumentations.Add(newSDDoc);
                curDB.SaveChanges();

                //Rebuilds document list for find reference
                DocumentList = curDB.SDDocumentations.Where(p => p.Status_id == 2).OrderBy(p => p.alias).ToList();
            }

            log();
        }