コード例 #1
0
        public ActionResult CreateStudy(Study_Material study_Material, HttpPostedFileBase fileUpload)
        {
            using (var ms = new MemoryStream())
            {
                fileUpload.InputStream.CopyTo(ms);
                study_Material.File = ms.ToArray();
            }
            if (ModelState.IsValid)
            {
                db.Study_Materials.Add(study_Material);
                db.SaveChanges();
                return(RedirectToAction("Study_Material"));
            }

            return(View(study_Material));
        }
コード例 #2
0
 public ActionResult Create([Bind(Include = "ID,announcementText,announcementDate,expiresAt")] Announcement announcement)
 {
     if (Session["userName"] != null)
     {
         if (ModelState.IsValid)
         {
             db.Announcements.Add(announcement);
             db.SaveChanges();
             return(RedirectToAction("Index"));
         }
         return(View(announcement));
     }
     else
     {
         return(RedirectToAction("Logout", "Admin"));
     }
 }
コード例 #3
0
        public ActionResult Create([Bind(Include = "ID,cyberAlertText,cyberAlertDate,expiresAt")] cyberAlert cyberAlert)
        {
            if (Session["userName"] != null)
            {
                if (ModelState.IsValid)
                {
                    db.cyberAlerts.Add(cyberAlert);
                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }

                return(View(cyberAlert));
            }
            else
            {
                return(RedirectToAction("Logout", "Admin"));
            }
        }
コード例 #4
0
        public ActionResult Create([Bind(Include = "ID,lectureTopic,speakerName,location,date")] Lecture lecture)
        {
            if (Session["userName"] != null)
            {
                if (ModelState.IsValid)
                {
                    db.Lectures.Add(lecture);
                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }

                return(View(lecture));
            }
            else
            {
                return(RedirectToAction("Logout", "Admin"));
            }
        }
コード例 #5
0
        public ActionResult Create([Bind(Include = "ID,quoteText,expiresAt")] Quote quote)
        {
            if (Session["userName"] != null)
            {
                if (ModelState.IsValid)
                {
                    db.Quotes.Add(quote);
                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }

                return(View(quote));
            }
            else
            {
                return(RedirectToAction("Logout", "Admin"));
            }
        }
コード例 #6
0
        public ActionResult Create(Synopsis synopsis, HttpPostedFileBase fileUpload)
        {
            if (Session["userName"] != null)
            {
                using (var ms = new MemoryStream())
                {
                    fileUpload.InputStream.CopyTo(ms);
                    synopsis.File = ms.ToArray();
                }
                if (ModelState.IsValid)
                {
                    db.Synopsis.Add(synopsis);
                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }

                return(View(synopsis));
            }
            else
            {
                return(RedirectToAction("Logout", "Admin"));
            }
        }
コード例 #7
0
        public ActionResult Create(Commandant commandant, HttpPostedFileBase ImageFile)
        {
            if (Session["userName"] != null)
            {
                using (var ms = new MemoryStream())
                {
                    ImageFile.InputStream.CopyTo(ms);
                    commandant.Image = ms.ToArray();
                }
                if (ModelState.IsValid)
                {
                    db.Commandants.Add(commandant);
                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }

                return(View(commandant));
            }
            else
            {
                return(RedirectToAction("Logout", "Admin"));
            }
        }
コード例 #8
0
        public ActionResult Create(Study_Material study_Material, HttpPostedFileBase fileUpload)
        {
            if (Session["userName"] != null)
            {
                //var extension = Path.GetExtension(fileUpload.FileName);
                using (var ms = new MemoryStream())
                {
                    fileUpload.InputStream.CopyTo(ms);
                    study_Material.File = ms.ToArray();
                }
                if (ModelState.IsValid)
                {
                    db.Study_Materials.Add(study_Material);
                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }

                return(View(study_Material));
            }
            else
            {
                return(RedirectToAction("Logout", "Admin"));
            }
        }