public void Delete(DiverCertification diverCertificationToDelete)
        {
            diverCertificationRepository.Delete(diverCertificationToDelete);

              try {
            diverCertificationRepository.DbContext.CommitChanges();
              }
              catch (Exception e) {
            diverCertificationRepository.DbContext.RollbackTransaction();
            throw new Exception("A problem was encountered preventing the certification from being deleted. " +
                            "Another item likely depends on this certification.");

              }
        }
        public virtual bool Equals(DiverCertification obj)
        {
            if (obj == null) return false;

              if (Equals(CertificationNum, obj.CertificationNum) == false)
            return false;

              if (Equals(Certified, obj.Certified) == false)
            return false;

              if (Equals(Created, obj.Created) == false)
            return false;

              if (Equals(LastModified, obj.LastModified) == false)
            return false;

              if (Equals(Notes, obj.Notes) == false)
            return false;

              return true;
        }
        public ActionResult Create(DiverCertificationModel model)
        {
            user = userServices.FindUser(this.User.Identity.Name);
              Diver diver = diverServices.GetDiverByContact(user.Contact.Id);
              if (ModelState.IsValid) {
            DiverCertification diverCertification = new DiverCertification();
            diverCertification.Diver = diver;
            diverCertification.Notes = model.Notes;
            diverCertification.CertificationNum = model.CertificationNum;
            diverCertification.Certified = model.Certified;
            diverCertification.Instructor = instructorServices.GetInstructor(model.InstructorId);
            diverCertification.Certification = certificationServices.Get(model.CertificationId);
            diverCertification.Created = System.DateTime.Now;
            diverCertification.LastModified = System.DateTime.Now;

            diverCertificationServices.Save(diverCertification);

            TempData[ControllerEnums.GlobalViewDataProperty.PageMessage.ToString()] = "The certification was successfully created.";
            return RedirectToAction("Index");
              }
              return View(model);
        }
 private void TransferFormValuesTo(DiverCertification diverCertificationToUpdate, DiverCertificationModel diverCertificationFromForm)
 {
     diverCertificationToUpdate.Notes = diverCertificationFromForm.Notes;
       diverCertificationToUpdate.CertificationNum = diverCertificationFromForm.CertificationNum;
       diverCertificationToUpdate.Certified = diverCertificationFromForm.Certified;
       diverCertificationToUpdate.Instructor = instructorServices.GetInstructor(diverCertificationFromForm.InstructorId);
       diverCertificationToUpdate.Certification = certificationServices.Get(diverCertificationFromForm.CertificationId);
       diverCertificationToUpdate.LastModified = System.DateTime.Now;
 }
 public void Save(DiverCertification diverCertification)
 {
     DiverCertification savedCertification = diverCertificationRepository.SaveOrUpdate(diverCertification);
       diverCertificationRepository.DbContext.CommitChanges();
 }