コード例 #1
0
        public ActionResult Create(ProfessionalQualification professionalqualification)
        {
            if (ModelState.IsValid)
            {
                db.ProfessionalQualifications.Add(professionalqualification);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            ViewBag.CertificationId = new SelectList(db.Certifications, "Id", "Title", professionalqualification.CertificationId);
            ViewBag.PersonalInfoId = new SelectList(db.PersonalInformations, "Id", "FathersName", professionalqualification.PersonalInfoId);
            return View(professionalqualification);
        }
        public ActionResult Create(ProfessionalQualification professionalqualification)
        {
            if (ModelState.IsValid)
            {
                var membership = (SimpleMembershipProvider)Membership.Provider;
                int idUser = membership.GetUserId(User.Identity.Name);
                int id = manager.GetPersonalInfoIdOfCurrentUser(idUser);
                professionalqualification.PersonalInfoId = id;
                db.ProfessionalQualifications.Add(professionalqualification);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            ViewBag.CertificationId = new SelectList(db.Certifications, "Id", "Title", professionalqualification.CertificationId);
            ViewBag.InstitutionId = new SelectList(db.Institutions, "Id", "Name", professionalqualification.InstitutionId);
            ViewBag.PersonalInfoId = new SelectList(db.PersonalInformations, "Id", "FirstName", professionalqualification.PersonalInfoId);
            return View(professionalqualification);
        }
 public ActionResult Edit(ProfessionalQualification professionalqualification)
 {
     if (ModelState.IsValid)
     {
         db.Entry(professionalqualification).State = EntityState.Modified;
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     ViewBag.CertificationId = new SelectList(db.Certifications, "Id", "Title", professionalqualification.CertificationId);
     ViewBag.InstitutionId = new SelectList(db.Institutions, "Id", "Name", professionalqualification.InstitutionId);
     ViewBag.PersonalInfoId = new SelectList(db.PersonalInformations, "Id", "FirstName", professionalqualification.PersonalInfoId);
     return View(professionalqualification);
 }