コード例 #1
0
ファイル: B2B.cs プロジェクト: janiukjf/CurtAdmin
        //////////////////////==  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);
            }
        }
コード例 #2
0
ファイル: B2BController.cs プロジェクト: janiukjf/CurtAdmin
        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();
        }
コード例 #3
0
ファイル: B2B.cs プロジェクト: janiukjf/CurtAdmin
 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);
     }
 }
コード例 #4
0
ファイル: B2B.cs プロジェクト: janiukjf/CurtAdmin
 ///////////////////////==  Delete    ==/////////////////////////
 public static string DeleteCert(int id)
 {
     try {
         B2BDataContext db = new B2BDataContext();
         B2BCertificate cert = new B2BCertificate();
         cert = db.B2BCertificates.Where(x => x.id == id).FirstOrDefault<B2BCertificate>();
         db.B2BCertificates.DeleteOnSubmit(cert);
         db.SubmitChanges();
         return "";
     } catch (Exception e) {
         return "Error while deleting" + e.Message;
     }
 }