コード例 #1
0
        public ActionResult ehee([Bind(Include = "TopicID,CommentA,CTID,MCID,StatusID,CTassignID")] ContentAssign contentAssign, int id)
        {
            contentAssign.CTassignID = contentAssign.CTassignID;
            ViewBag.StatusID         = new SelectList(db.Status, "StatusID", "GiveStatus");

            var tpid = (from tp in db.Topics join t in db.ContentAssigns on tp.TopicID equals t.TopicID where t.CTassignID == id select new { Name = tp.TopicID }).FirstOrDefault();

            contentAssign.TopicID = tpid.Name;

            var cid = (from c in db.Contents join t in db.ContentAssigns on c.CTID equals t.CTID where t.CTassignID == id select new { ID = c.CTID }).FirstOrDefault();

            contentAssign.CTID = cid.ID;

            var m = (from s in db.MarketingCoordinators
                     where s.UserName.Equals(User.Identity.Name)
                     select s).FirstOrDefault();

            contentAssign.MCID = m.MCID;
            if (ModelState.IsValid)
            {
                db.Entry(contentAssign).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(contentAssign));
        }
コード例 #2
0
 public ActionResult Edit(Guest guest)
 {
     if (ModelState.IsValid)
     {
         db.Entry(guest).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(guest));
 }
コード例 #3
0
        public ActionResult Edit(string id1, HttpPostedFileBase postedImg, HttpPostedFileBase postedPDF, Content ct)
        {
            byte[] bytes;
            byte[] byte2s;
            using (BinaryReader br = new BinaryReader(postedImg.InputStream))
            {
                bytes = br.ReadBytes(postedImg.ContentLength);
            }
            using (BinaryReader br2 = new BinaryReader(postedPDF.InputStream))
            {
                byte2s = br2.ReadBytes(postedPDF.ContentLength);
            }

            var student = (from s in db.Students
                           where s.UserName.Equals(User.Identity.Name)
                           select s).FirstOrDefault();

            var tpid = (from t in db.Topics
                        where t.TopicID.Equals(ct.TopicID)
                        select t).FirstOrDefault();

            ViewBag.StudentName = student.StudentName;
            ViewBag.StudentID   = student.StudentID;
            ViewBag.FacultyID   = student.Faculty.FacultyID;
            ViewBag.TopicID     = new SelectList(db.Topics.Where(g => g.FacultyID == student.Faculty.FacultyID).ToList(), "TopicID", "TopicName");

            if (DateTime.Now < (DateTime)tpid.EndDate)
            {
                if (ModelState.IsValid)
                {
                    ct.StudentID       = ViewBag.StudentID;
                    ct.FacultyID       = ViewBag.FacultyID;
                    ct.Name2           = Path.GetFileName(postedImg.FileName);
                    ct.ContentType2    = postedImg.ContentType;
                    ct.Data2           = bytes;
                    ct.Name            = Path.GetFileName(postedPDF.FileName);
                    ct.Data            = byte2s;
                    ct.ContentType     = postedPDF.ContentType;
                    db.Entry(ct).State = EntityState.Modified;
                    db.SaveChanges();
                    return(RedirectToAction("Uploaded"));
                }
            }
            else
            {
                TempData["message"] = "You can't edit because this topic is expired ";
                return(View());
            }
            return(View(ct));
        }
コード例 #4
0
        public ActionResult Edit([Bind(Include = "StudentEmail,StudentID,StudentName,StudentAddress,DOB,UserName,FacultyID")] Student student)
        {
            ViewBag.StdID     = (from i in db.Students where i.UserName == User.Identity.Name select i.StudentID).FirstOrDefault();
            ViewBag.Fac       = (from i in db.Students where i.UserName == User.Identity.Name select i.Faculty.FacultyName).FirstOrDefault();
            ViewBag.FacultyID = new SelectList(db.Faculties, "FacultyID", "FacultyName", student.FacultyID);
            if (ModelState.IsValid)
            {
                db.Entry(student).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(student));
        }
コード例 #5
0
        public ActionResult Edit([Bind(Include = "MCEmail,MCID,MCName,MCAddress,MCPhone,FacultyID,UserName")] MarketingCoordinator marketingCoordinator)
        {
            var mID   = (from i in db.MarketingCoordinators where i.UserName == User.Identity.Name select i.MCID).FirstOrDefault();
            var uName = (from m in db.MarketingCoordinators where m.UserName == User.Identity.Name select m.UserName).FirstOrDefault();
            var facID = (from c in db.MarketingCoordinators where c.UserName == User.Identity.Name select c.FacultyID).FirstOrDefault();

            if (ModelState.IsValid)
            {
                db.Entry(marketingCoordinator).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.FacultyID = new SelectList(db.Faculties, "FacultyID", "FacultyName", marketingCoordinator.FacultyID);
            return(View(marketingCoordinator));
        }
コード例 #6
0
        public ActionResult Edit([Bind(Include = "StudentEmail,StudentName,StudentID,StudentAddress,FacultyID,DOB,UserName")] Student student)
        {
            var stdID = (from i in db.Students where i.UserName == User.Identity.Name select i.StudentID).FirstOrDefault();
            var uName = (from m in db.Students where m.UserName == User.Identity.Name select m.UserName).FirstOrDefault();
            var facID = (from c in db.Students where c.UserName == User.Identity.Name select c.FacultyID).FirstOrDefault();

            if (ModelState.IsValid)
            {
                student.StudentID       = stdID;
                student.FacultyID       = facID;
                student.UserName        = uName;
                db.Entry(student).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("StdProfile"));
            }

            return(View(student));
        }
コード例 #7
0
        public ActionResult Edit(MarketingManager marketingmanager)
        {
            var a = (from s in db.MarketingManagers
                     where s.UserName == User.Identity.Name
                     select s.UserName).FirstOrDefault();

            if (ModelState.IsValid)
            {
                marketingmanager.UserName        = a;
                db.Entry(marketingmanager).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index", "Home"));
            }



            return(View(marketingmanager));
        }
コード例 #8
0
 public ActionResult Edit(Topic tp, string id)
 {
     ViewBag.TopicID = (from i in db.Topics
                        where i.TopicID == id
                        select i.TopicID).FirstOrDefault();
     ViewBag.FacultyID = new SelectList(db.Faculties, "FacultyID", "FacultyName", tp.FacultyID);
     if (tp.EndDate > tp.StartDate)
     {
         if (ModelState.IsValid)
         {
             tp.TopicID         = ViewBag.TopicID;
             db.Entry(tp).State = EntityState.Modified;
             db.SaveChanges();
             return(RedirectToAction("Index"));
         }
     }
     else
     {
         TempData["message"] = "The End Date must come after the Start Date";
         return(View());
     }
     return(View(tp));
 }