Beispiel #1
0
        public virtual bool Equals(Instructor obj)
        {
            if (obj == null) return false;

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

              return true;
        }
 public void Delete(Instructor instructor)
 {
     try
     {
         InstructorRepository.Delete(instructor);
         InstructorRepository.DbContext.CommitChanges();
     }
     catch (Exception e)
     {
         log.Error("Cound not delete instructor. Something else probably references this instructor",e);
         throw e;
     }
     return;
 }
        private void saveNewContact(ContactModel model)
        {
            this.user = userServices.FindUser(this.User.Identity.Name);
              Contact contact = new Contact();
              contact = UpdateContactFromModel(contact, model);
              contact.User = this.user;
              contact.Created = DateTime.Now;
              contact.LastModified = DateTime.Now;
              contactServices.Save(contact);

              if (model.isDiver) {
            Diver diver = new Diver();
            diver.Contact = contact;
            diverServices.Save(diver);
              }
              if (model.isInstructor) {
            Instructor instructor = new Instructor();
            instructor.Contact = contact;
            instructorServices.Save(instructor);
              }

              if (model.isAgency) {
            DiveAgency agency = new DiveAgency();
            agency.Contact = contact;
            diveAgencyServices.Save(agency);
              }

              if (model.isManufacturer) {
            Manufacturer manufacturer = new Manufacturer();
            manufacturer.Contact = contact;
            manufacturerServices.Save(manufacturer);
              }

              if (model.isDiveShop)
              {
            DiveShop diveShop = new DiveShop();
            diveShop.Contact = contact;
            diveShopServices.Save(diveShop);
              }
        }
        public Instructor Save(Instructor instructor)
        {
            try
            {
                //instructor.LastModifed = System.DateTime.Now;

                InstructorRepository.SaveOrUpdate(instructor);
                InstructorRepository.DbContext.CommitChanges();
            }
            catch (Exception e)
            {
                log.Error("Unable to save instructor ", e);
                throw e;
            }
            return instructor;
        }