示例#1
0
        public ActionResult Create(List <Ta_Wishes> ta_Wishes)
        {
            Ta_Wishes TA   = new Ta_Wishes();
            var       TAId = User.Identity.GetUserId();

            // ta_Wishes.Ta_Id = TAId;

            if (ModelState.IsValid)
            {
                foreach (var i in ta_Wishes)
                {
                    i.Ta_Id = TAId;


                    if (i.Priority != 0)
                    {
                        db.Ta_Wishes.Add(i);
                    }
                }

                db.SaveChanges();

                return(View(ta_Wishes));
            }
            ViewBag.Year_id = new SelectList(db.Years, "ID", "Year1", TA.Year_id);
            // ViewBag.Course_Id2 = new SelectList(db.Courses, "ID", "Name", TA.Course_Id);
            ViewBag.Course_Id = new SelectList(db.Courses, "ID", "Name", TA.Course_Id);


            return(View(ta_Wishes));
        }
        public ActionResult DeleteConfirmed(int id)
        {
            Ta_Wishes ta_Wishes = db.Ta_Wishes.Find(id);

            db.Ta_Wishes.Remove(ta_Wishes);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
 public ActionResult Edit([Bind(Include = "ID,Course_Id,Priority,Ta_Id,isAccepted,Year_id")] Ta_Wishes ta_Wishes)
 {
     if (ModelState.IsValid)
     {
         db.Entry(ta_Wishes).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.Ta_Id     = new SelectList(db.AspNetUsers, "Id", "Email", ta_Wishes.Ta_Id);
     ViewBag.Course_Id = new SelectList(db.Courses, "ID", "Name", ta_Wishes.Course_Id);
     ViewBag.Year_id   = new SelectList(db.Years, "ID", "Year1", ta_Wishes.Year_id);
     return(View(ta_Wishes));
 }
        // GET: Ta_Wishes/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Ta_Wishes ta_Wishes = db.Ta_Wishes.Find(id);

            if (ta_Wishes == null)
            {
                return(HttpNotFound());
            }
            return(View(ta_Wishes));
        }
        // GET: Ta_Wishes/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Ta_Wishes ta_Wishes = db.Ta_Wishes.Find(id);

            if (ta_Wishes == null)
            {
                return(HttpNotFound());
            }
            ViewBag.Ta_Id     = new SelectList(db.AspNetUsers, "Id", "Email", ta_Wishes.Ta_Id);
            ViewBag.Course_Id = new SelectList(db.Courses, "ID", "Name", ta_Wishes.Course_Id);
            ViewBag.Year_id   = new SelectList(db.Years, "ID", "Year1", ta_Wishes.Year_id);
            return(View(ta_Wishes));
        }