示例#1
0
        public ActionResult Edit([Bind(Include = "MentorshipID,ThesisTypeID,MentorshipTypeID,PersonID,Student,ThesisTitle,Remarks,Year,Semester")] MentorshipViewModel mentorshipViewModel)
        {
            if (ModelState.IsValid)
            {
                Mentorship model = db.Mentorships.Find(mentorshipViewModel.MentorshipID);

                model.ThesisTypeID     = mentorshipViewModel.ThesisTypeID;
                model.MentorshipTypeID = mentorshipViewModel.MentorshipTypeID;
                model.PersonID         = mentorshipViewModel.PersonID;
                model.Student          = mentorshipViewModel.Student;
                model.ThesisTitle      = mentorshipViewModel.ThesisTitle;
                model.Remarks          = mentorshipViewModel.Remarks;
                model.Year             = mentorshipViewModel.Year;
                model.Semester         = mentorshipViewModel.Semester;

                model.DateModified   = DateTime.Now;
                model.UserModifiedID = Guid.Parse(User.Identity.GetUserId());

                db.Entry(model).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            PopulateThesisTypesDropDownList(mentorshipViewModel.ThesisTypeID, mentorshipViewModel.MentorshipTypeID);
            PopulatePersonsDropDownList(mentorshipViewModel.PersonID);
            return(View(mentorshipViewModel));
        }