Exemple #1
0
        public static void addLesson(int catID, string title, string text, string pdf, bool inActive)
        {
            try {
                B2BDataContext db = new B2BDataContext();

                B2BLesson newLesson = new B2BLesson();
                newLesson.catID = catID;
                newLesson.title = title;
                newLesson.Text = text;
                newLesson.date_added = DateTime.Now;
                newLesson.date_modified = DateTime.Now;
                newLesson.inactive = inActive;

                db.B2BLessons.InsertOnSubmit(newLesson);
                db.SubmitChanges();

                B2BResource newPDF = new B2BResource();

                newPDF.file_path = pdf;
                newPDF.date_added = DateTime.Now;
                newPDF.sort = 1;
                newPDF.lessonID = newLesson.id;
                newPDF.title = title + " PDF";
                newPDF.image_path = "https://www.curtmfg.com/assets/f70444af-54b2-4242-8eca-13dacd6e715c.png";
                db.B2BResources.InsertOnSubmit(newPDF);
                db.SubmitChanges();

            } catch (Exception e) {
                throw new Exception("Could not add Lesson: " + e.Message);
            }
        }
Exemple #2
0
 public static void addAnswer(int questionID, string text, bool isCorrect, bool inActive)
 {
     try {
         B2BDataContext db = new B2BDataContext();
         B2BAnswer newAnswer = new B2BAnswer();
         newAnswer.questionID = questionID;
         newAnswer.text = text;
         newAnswer.isCorrect = isCorrect;
         newAnswer.date_added = DateTime.Now;
         newAnswer.date_modified = DateTime.Now;
         newAnswer.inactive = inActive;
         db.B2BAnswers.InsertOnSubmit(newAnswer);
         db.SubmitChanges();
     } catch (Exception e) {
         throw new Exception("Could not add Answer: " + e.Message);
     }
 }
Exemple #3
0
        public static void addCat(int certID, string title, string text, string image_path, bool inActive)
        {
            try {
                B2BDataContext db = new B2BDataContext();

                B2BCategory newCat = new B2BCategory();
                newCat.certID = certID;
                newCat.title = title;
                newCat.text = text;
                newCat.image_path = image_path;
                newCat.date_added = DateTime.Now;
                newCat.date_modified = DateTime.Now;
                newCat.inactive = inActive;
                db.B2BCategories.InsertOnSubmit(newCat);
                db.SubmitChanges();
            } catch (Exception e) {
                throw new Exception("Could not add category: " + e.Message);
            }
        }
Exemple #4
0
        //////////////////////==  Create  ==////////////////////////////
        public static void addCert(string title, string text, int reqNum, string image_path, bool inActive)
        {
            try {
                B2BDataContext db = new B2BDataContext();

                B2BCertificate newCertificate = new B2BCertificate();

                newCertificate.title = title;
                newCertificate.text = text;
                newCertificate.requirementNum = reqNum;
                newCertificate.image_path = image_path;
                newCertificate.date_added = DateTime.Now;
                newCertificate.date_modified = DateTime.Now;
                newCertificate.inactive = inActive;

                db.B2BCertificates.InsertOnSubmit(newCertificate);
                db.SubmitChanges();

            } catch (Exception e) {
                throw new Exception("Could not add certificate: " + e.Message);
            }
        }
Exemple #5
0
 public static B2BTest getTest(int testID)
 {
     try {
         B2BDataContext db = new B2BDataContext();
         B2BTest test = new B2BTest();
         test = db.B2BTests.Where(x => x.id == testID).Select(x => x).FirstOrDefault<B2BTest>();
         return test;
     } catch (Exception e) {
         throw new Exception("Could not load the test: " + e.Message);
     }
 }
Exemple #6
0
 public static string DeleteTest(int id)
 {
     try {
         B2BDataContext db = new B2BDataContext();
         B2BTest test = new B2BTest();
         test = db.B2BTests.Where(x => x.id == id).FirstOrDefault<B2BTest>();
         db.B2BTests.DeleteOnSubmit(test);
         db.SubmitChanges();
         return "";
     } catch (Exception) {
         return "Error while deleting";
     }
 }
Exemple #7
0
        public ActionResult EditTest(int id, string title, string text, double minPassPercent, string inactive)
        {
            ViewBag.error = "";
            if (id > 0) {
                Boolean inActive = false;
                inActive = (inactive == "on") ? true : false;

                // retrieve the test with the id
                try {
                    B2BDataContext db = new B2BDataContext();
                    B2BTest test = new B2BTest();
                    test = db.B2BTests.Where(x => x.id == id).FirstOrDefault<B2BTest>();
                    test.title = title;
                    test.text = text;
                    test.min_pass_percent = minPassPercent;
                    test.inactive = inActive;
                    db.SubmitChanges();

                    ViewBag.test = test;
                    ViewBag.msg = "The test changes have been made.";
                } catch (Exception e) {
                    ViewBag.error = e.Message;
                }
            } else {
                return RedirectToAction("Index");
            }
            return View();
        }
Exemple #8
0
 // get individual objects
 public static B2BAnswer getAnswer(int answerID)
 {
     try {
         B2BDataContext db = new B2BDataContext();
         B2BAnswer answer = new B2BAnswer();
         answer = db.B2BAnswers.Where(x => x.id == answerID).Select(x => x).FirstOrDefault<B2BAnswer>();
         return answer;
     } catch (Exception e) {
         throw new Exception("could not retrieve the answer: " + e.Message);
     }
 }
Exemple #9
0
        ///////////////////== AJAX == ////////////////////////////////////
        public static string SetPlaqueStatus(int certID, int userID)
        {
            try {
                B2BDataContext db = new B2BDataContext();
                B2BCompletedCert compCert = new B2BCompletedCert();
                B2BUser b2bUser = getB2BUser(userID);
                compCert = db.B2BCompletedCerts.Where(x => x.certID == certID && x.B2BUserID == b2bUser.id).FirstOrDefault<B2BCompletedCert>();
                if (compCert.hasPlaque == false) {
                    compCert.hasPlaque = true;
                } else {
                    compCert.hasPlaque = false;
                }
                db.SubmitChanges();

                return "";
            } catch (Exception e) {
                return "Error setting plaque status";
            }
        }
Exemple #10
0
 public static List<B2BVideoType> getVideoTypes()
 {
     try {
         List<B2BVideoType> listOfVideoTypes = new List<B2BVideoType>();
         B2BDataContext db = new B2BDataContext();
         listOfVideoTypes = db.B2BVideoTypes.ToList<B2BVideoType>();
         return listOfVideoTypes;
     } catch (Exception e) {
         throw new Exception("Could not load B2B video types: " + e.Message);
     }
 }
Exemple #11
0
 public static List<B2BCategory> getCategories(int certID)
 {
     try {
         B2BDataContext db = new B2BDataContext();
         List<B2BCategory> listOfCategories = new List<B2BCategory>();
         listOfCategories = db.B2BCategories.Where(x => x.certID == certID).Select(x => x).ToList<B2BCategory>();
         return listOfCategories;
     } catch (Exception e) {
         throw new Exception("Could not load categories: " + e.Message);
     }
 }
Exemple #12
0
        public static List<B2BFullUser> getB2BUsers(int custID = 0)
        {
            List<B2BUser> listOfB2BUsers = new List<B2BUser>();
            B2BDataContext db = new B2BDataContext();
            CurtDevDataContext cdb = new CurtDevDataContext();
            if (custID == 0) {
                listOfB2BUsers = db.B2BUsers.ToList<B2BUser>();
            } else {

                List<CustomerUser> listOfUsers = cdb.CustomerUsers.Where(x => x.cust_id == custID).ToList<CustomerUser>();
                foreach (CustomerUser user in listOfUsers) {
                   B2BUser b2bUser = db.B2BUsers.Where(x => x.customerUserEmail == user.email).FirstOrDefault<B2BUser>();
                   if (b2bUser != null) {
                       listOfB2BUsers.Add(b2bUser);
                   }
                }

            }

            List<B2BFullUser> listOfFullUsers = new List<B2BFullUser>();
            foreach (B2BUser user in listOfB2BUsers) {
                listOfFullUsers.Add(B2BFullUser.castToFullUser(user)); // add the generated full user to the list of Full Users
            }// end foreach b2b user

            return listOfFullUsers;
        }
Exemple #13
0
 public static B2BUser getB2BUser(string customerUserEmail)
 {
     try {
         B2BUser b2bUser = new B2BUser();
         B2BDataContext db = new B2BDataContext();
         b2bUser = db.B2BUsers.Where(x => x.customerUserEmail == customerUserEmail).Select(x => x).FirstOrDefault<B2BUser>();
         return b2bUser;
     } catch (Exception) {
         throw new Exception("Could not retrieve B2B user information.");
     }
 }
Exemple #14
0
 public static B2BUser getB2BUser(int b2bUserID)
 {
     try {
         // get b2b user with the id being passed in
         B2BDataContext db = new B2BDataContext();
         B2BUser b2bUser = db.B2BUsers.Where(x => x.id == b2bUserID).Select(x => x).FirstOrDefault<B2BUser>();
         return b2bUser;
     } catch (Exception e) {
         throw new Exception("Could not load B2B User Info: " + e.Message);
     }
 }
Exemple #15
0
 public static B2BFullUser getB2BFullUser(int b2bUserID)
 {
     try {
         // get b2b user with the id being passed in
         B2BDataContext db = new B2BDataContext();
         B2BUser b2bUser = db.B2BUsers.Where(x => x.id == b2bUserID).Select(x => x).FirstOrDefault<B2BUser>();
         // cast b2b user to full user and return it
         return B2BFullUser.castToFullUser(b2bUser);
     } catch (Exception e) {
         throw new Exception("Could get get B2B user: " + e.Message);
     }
 }
Exemple #16
0
        public static List<Customer> getB2BCustomers()
        {
            B2BDataContext b2bdb = new B2BDataContext();
            CurtDevDataContext db = new CurtDevDataContext();
            // get list of users emails.
            List<string> listofEmails = b2bdb.B2BUsers.Select(x => x.customerUserEmail).ToList<string>();

            List<CustomerUser> users = new List<CustomerUser>();
            // loop through the list of emails and get the users with those emails.
            foreach (string email in listofEmails) {
                users.Add(db.CustomerUsers.Where(x => x.email == email).FirstOrDefault<CustomerUser>());
            }
            List<Customer> listOfCustomers = new List<Customer>();
            // grab all the distinct customer records from that list of users.
            listOfCustomers = users.Select(x => x.Customer).Distinct().ToList<Customer>();
            return listOfCustomers;
        }
Exemple #17
0
 public static List<B2BTest> getTests(int lessonID)
 {
     try {
         B2BDataContext db = new B2BDataContext();
         List<B2BTest> listOfTests = new List<B2BTest>();
         listOfTests = db.B2BTests.Where(x => x.lessonID == lessonID).Select(x => x).ToList<B2BTest>();
         return listOfTests;
     } catch (Exception e) {
         throw new Exception("could not load tests: " + e.Message);
     }
 }
Exemple #18
0
 public static B2BCategory getCategory(int catID)
 {
     try {
         B2BDataContext db = new B2BDataContext();
         B2BCategory cat = new B2BCategory();
         cat = db.B2BCategories.Where(x => x.id == catID).Select(x => x).FirstOrDefault<B2BCategory>();
         return cat;
     } catch (Exception e) {
         throw new Exception("Could not load category: " + e.Message);
     }
 }
Exemple #19
0
 public static B2BVideo getVideo(int videoID)
 {
     try {
         B2BDataContext db = new B2BDataContext();
         B2BVideo video = new B2BVideo();
         video = db.B2BVideos.Where(x => x.id == videoID).Select(x => x).FirstOrDefault<B2BVideo>();
         return video;
     } catch (Exception e) {
         throw new Exception("Could not laod the video: " + e.Message);
     }
 }
Exemple #20
0
        public ActionResult EditAnswer(int id, string text, string isCorrect, string inactive)
        {
            ViewBag.error = "";

            Boolean inActive = false;
            inActive = (inactive == "on") ? true : false;

            bool isCorrectAnswer = false;
            if (isCorrect == "on") { isCorrectAnswer = true; } else { isCorrectAnswer = false; }
            if (id > 0) {
                // retrieve the answer with the id
                try {
                    B2BDataContext db = new B2BDataContext();
                    B2BAnswer answer = new B2BAnswer();
                    answer = db.B2BAnswers.Where(x => x.id == id).FirstOrDefault<B2BAnswer>();
                    answer.text = text;
                    answer.isCorrect = isCorrectAnswer;
                    answer.inactive = inActive;
                    db.SubmitChanges();

                    ViewBag.answer = answer;
                    ViewBag.msg = "The answer has been changed.";
                } catch (Exception e) {
                    ViewBag.error = e.Message;
                }
            } else {
                return RedirectToAction("Index");
            }
            return View();
        }
Exemple #21
0
        public static bool isCustomerUser(string custID)
        {
            B2BDataContext dbB2B = new B2BDataContext();
            CurtDevDataContext db = new CurtDevDataContext();

            CustomerUser customerUserCheck = db.CustomerUsers.Where(x => x.id.ToString() == custID.ToString()).Select(x => x).FirstOrDefault<CustomerUser>();
            if (customerUserCheck == null) {
                // the b2bUser is a customer
                return false;
            } else {
                // the b2bUser is a customer User
                return true;
            }
        }
Exemple #22
0
        public ActionResult EditLesson(int id, string title, string text, string pdf, string inactive)
        {
            ViewBag.error = "";
            if (id > 0) {
                Boolean inActive = false;
                inActive = (inactive == "on") ? true : false;

                // retrieve the lesson with the id
                try {
                    B2BDataContext db = new B2BDataContext();
                    B2BLesson lesson = new B2BLesson();
                    lesson = db.B2BLessons.Where(x => x.id == id).FirstOrDefault<B2BLesson>();
                    lesson.title = title;
                    lesson.Text = text;
                    lesson.inactive = inActive;
                    db.SubmitChanges();

                    B2BVideo videoObj = new B2BVideo();
                    videoObj = db.B2BVideos.Where(x => x.lessonID == lesson.id).FirstOrDefault<B2BVideo>();
                    db.SubmitChanges();

                    B2BResource pdfObj = new B2BResource();
                    pdfObj = db.B2BResources.Where(x => x.lessonID.Equals(lesson.id)).FirstOrDefault<B2BResource>();
                    pdfObj.file_path = pdf;
                    db.SubmitChanges();

                    ViewBag.lesson = lesson;
                    ViewBag.video = videoObj;
                    ViewBag.pdf = pdfObj;

                    ViewBag.msg = "The Lesson changes have been made.";
                } catch (Exception e) {
                    ViewBag.error = e.Message;
                }
            } else {
                return RedirectToAction("Index");
            }
            return View();
        }
Exemple #23
0
 public static B2BCertificate getCertificate(int certID)
 {
     try {
         B2BDataContext db = new B2BDataContext();
         B2BCertificate cert = new B2BCertificate();
         cert = db.B2BCertificates.Where(x => x.id == certID).Select(x => x).FirstOrDefault<B2BCertificate>();
         return cert;
     } catch (Exception e) {
         throw new Exception("Could not load certificate: " + e.Message);
     }
 }
Exemple #24
0
 public static string DeleteVideo(int id)
 {
     try {
         B2BDataContext db = new B2BDataContext();
         B2BVideo video = new B2BVideo();
         video = db.B2BVideos.Where(x => x.id == id).FirstOrDefault<B2BVideo>();
         db.B2BVideos.DeleteOnSubmit(video);
         db.SubmitChanges();
         return "";
     } catch (Exception) {
         return "Error while deleting";
     }
 }
Exemple #25
0
        public ActionResult EditCert(int id, string title, string text, int reqNum, string logo, string inactive)
        {
            ViewBag.error = "";
            if (id > 0) {
                Boolean inActive = false;
                inActive = (inactive == "on") ? true : false;

                // retrieve the cert with the id
                try {
                    B2BDataContext db = new B2BDataContext();
                    B2BCertificate cert = new B2BCertificate();
                    cert = db.B2BCertificates.Where(x => x.id == id).FirstOrDefault<B2BCertificate>();
                    cert.title = title;
                    cert.text = text;
                    cert.requirementNum = reqNum;
                    cert.image_path = logo;
                    cert.inactive = inActive;
                    db.SubmitChanges();

                    ViewBag.cert = cert;
                    ViewBag.msg = "The certificate changes have been made.";
                } catch (Exception e) {
                    ViewBag.error = e.Message;
                }
            } else {
                return RedirectToAction("Index");
            }
            return View();
        }
Exemple #26
0
 //////////////////////==  Read   ==/////////////////////////////
 public static List<B2BCertificate> getCertificates()
 {
     try {
         B2BDataContext db = new B2BDataContext();
         List<B2BCertificate> listOfCertificates = new List<B2BCertificate>();
         listOfCertificates = db.B2BCertificates.Select(x => x).ToList<B2BCertificate>();
         return listOfCertificates;
     } catch (Exception e) {
         throw new Exception("Could not load certificates: " + e.Message);
     }
 }
Exemple #27
0
        public ActionResult EditQuestion(int id, string text, string inactive)
        {
            ViewBag.error = "";
            if (id > 0) {
                Boolean inActive = false;
                inActive = (inactive == "on") ? true : false;

                // retrieve the question with the id
                try {
                    B2BDataContext db = new B2BDataContext();
                    B2BQuestion question = new B2BQuestion();
                    question = db.B2BQuestions.Where(x => x.id == id).FirstOrDefault<B2BQuestion>();
                    question.text = text;
                    question.inactive = inActive;
                    db.SubmitChanges();

                    ViewBag.question = question;
                    ViewBag.msg = "The question has been changed.";
                } catch (Exception e) {
                    ViewBag.error = e.Message;
                }
            } else {
                return RedirectToAction("Index");
            }
            return View();
        }
Exemple #28
0
 public static List<B2BLesson> getLessons(int catID)
 {
     try {
         B2BDataContext db = new B2BDataContext();
         List<B2BLesson> listOfLessons = new List<B2BLesson>();
         listOfLessons = db.B2BLessons.Where(x => x.catID == catID).Select(x => x).ToList<B2BLesson>();
         return listOfLessons;
     } catch (Exception e) {
         throw new Exception("Could not load lessons: " + e.Message);
     }
 }
Exemple #29
0
        public ActionResult EditVideo(int id, string title, string mp4, string ogg, string webm, string inactive)
        {
            ViewBag.error = "";
            Boolean inActive = false;
            inActive = (inactive == "on") ? true : false;
            bool isCorrectAnswer = false;
            if (id > 0 && title != "") {
                // retrieve the video with the id
                try {
                    B2BDataContext db = new B2BDataContext();
                    B2BVideo video = db.B2BVideos.Where(x => x.id == id).FirstOrDefault<B2BVideo>();
                    video.title = title;
                    video.inactive = inActive;
                    db.SubmitChanges();

                    if (mp4.Length > 0) {
                        B2BVideoSource mp4videoSrc = new B2BVideoSource();
                        mp4videoSrc = video.B2BVideoSources.Where(x => x.VideoTypes.type == "mp4").Select(x => x).FirstOrDefault<B2BVideoSource>();
                        if (mp4videoSrc != null) {
                            mp4videoSrc.filePath = mp4;
                            db.SubmitChanges();
                        } else {
                            B2BVideoSource newMp4Source = new B2BVideoSource();
                            newMp4Source.filePath = mp4;
                            newMp4Source.videoID = id;
                            B2BVideoType videoType = B2B.getVideoTypes().Where(x => x.type == "mp4").FirstOrDefault();
                            newMp4Source.typeID = videoType.id;
                            db.B2BVideoSources.InsertOnSubmit(newMp4Source);
                            db.SubmitChanges();
                        }
                    }

                    if (ogg.Length > 0) {
                        B2BVideoSource oggvideoSrc = new B2BVideoSource();
                        oggvideoSrc = video.B2BVideoSources.Where(x => x.VideoTypes.type == "ogg").Select(x => x).FirstOrDefault<B2BVideoSource>();
                        if (oggvideoSrc != null) {
                            oggvideoSrc.filePath = ogg;
                            db.SubmitChanges();
                        } else {
                            B2BVideoSource newoggSource = new B2BVideoSource();
                            newoggSource.filePath = ogg;
                            newoggSource.videoID = id;
                            B2BVideoType videoType = B2B.getVideoTypes().Where(x => x.type == "ogg").FirstOrDefault();
                            newoggSource.typeID = videoType.id;
                            db.B2BVideoSources.InsertOnSubmit(newoggSource);
                            db.SubmitChanges();
                        }
                    }

                    if (webm.Length > 0) {
                        B2BVideoSource webmvideoSrc = new B2BVideoSource();
                        webmvideoSrc = video.B2BVideoSources.Where(x => x.VideoTypes.type == "webm").Select(x => x).FirstOrDefault<B2BVideoSource>();
                        if (webmvideoSrc != null) {
                            webmvideoSrc.filePath = webm;
                            db.SubmitChanges();
                        } else {
                            B2BVideoSource newwebmSource = new B2BVideoSource();
                            newwebmSource.filePath = webm;
                            newwebmSource.videoID = id;
                            B2BVideoType videoType = B2B.getVideoTypes().Where(x => x.type == "webm").FirstOrDefault();
                            newwebmSource.typeID = videoType.id;
                            db.B2BVideoSources.InsertOnSubmit(newwebmSource);
                            db.SubmitChanges();
                        }
                    }

                    ViewBag.msg = "The video has been changed.";

                    ViewBag.video = video;
                    ViewBag.lesson = B2B.getLesson(video.lessonID);
                    B2BVideoSource videoSrc = new B2BVideoSource();
                    videoSrc = video.B2BVideoSources.Where(x => x.VideoTypes.type == "mp4").Select(x => x).FirstOrDefault<B2BVideoSource>();
                    ViewBag.mp4 = videoSrc.filePath;

                    videoSrc = video.B2BVideoSources.Where(x => x.VideoTypes.type == "ogg").Select(x => x).FirstOrDefault<B2BVideoSource>();
                    ViewBag.ogg = videoSrc.filePath;

                    videoSrc = video.B2BVideoSources.Where(x => x.VideoTypes.type == "webm").Select(x => x).FirstOrDefault<B2BVideoSource>();
                    ViewBag.webm = videoSrc.filePath;
                } catch (Exception e) {
                    ViewBag.error = e.Message;
                }
            } else {
                return RedirectToAction("Index");
            }
            return View();
        }
Exemple #30
0
 public static B2BQuestion getQuestion(int questionID)
 {
     try {
         B2BDataContext db = new B2BDataContext();
         B2BQuestion question = new B2BQuestion();
         question = db.B2BQuestions.Where(x => x.id == questionID).Select(x => x).FirstOrDefault<B2BQuestion>();
         return question;
     } catch (Exception e) {
         throw new Exception("Could not load the question: " + e.Message);
     }
 }