コード例 #1
0
        public int UpdatePhysician(string HomeAddress, string HomePhone, string OfficeAddress, string OfficePhone, string EmailAddress, string CellphoneNumber, string Name, string Description, int Id, string FirstName, string MiddleName, string LastName, DateTime BirthDate, string Gender, double?Weight, double?Height)
        {
            PhysicianDBEntities db   = new PhysicianDBEntities();
            Physician           phys = new Physician();
            ContactInformation  cont = new ContactInformation();
            Specialization      spec = new Specialization();

            phys.Id              = Id;
            phys.FirstName       = FirstName;
            phys.MiddleName      = MiddleName;
            phys.LastName        = LastName;
            phys.BirthDate       = BirthDate;
            phys.Gender          = Gender;
            phys.Weight          = Weight;
            phys.Height          = Height;
            cont.Id              = Id;
            cont.HomeAddress     = HomeAddress;
            cont.HomePhone       = HomePhone;
            cont.OfficeAddress   = OfficeAddress;
            cont.OfficePhone     = OfficePhone;
            cont.EmailAddress    = EmailAddress;
            cont.CellphoneNumber = CellphoneNumber;
            spec.Id              = Id;
            spec.Name            = Name;
            spec.Description     = Description;
            //phys.ContactInformation = new ContactInformation
            //{
            //     Id = Id,
            //    HomeAddress = HomeAddress,
            //    HomePhone = HomePhone,
            //    OfficeAddress = OfficeAddress,
            //    OfficePhone = OfficePhone,
            //    EmailAddress = EmailAddress,
            //    CellphoneNumber = CellphoneNumber
            //};
            //phys.Specialization = new Specialization
            //{
            //     Id = Id,
            //    Name = Name,
            //    Description = Description
            //};

            db.Entry(phys).State = EntityState.Modified;
            db.Entry(cont).State = EntityState.Modified;
            db.Entry(spec).State = EntityState.Modified;
            int Retval = db.SaveChanges();

            return(Retval);
        }
コード例 #2
0
        public int DeletePhysicianById(int Id)
        {
            PhysicianDBEntities tstDb = new PhysicianDBEntities();
            Specialization      spec  = new Specialization();
            ContactInformation  cont  = new ContactInformation();
            Physician           phys  = new Physician();

            spec.Id = Id;
            cont.Id = Id;
            phys.Id = Id;
            tstDb.Entry(spec).State = EntityState.Deleted;
            tstDb.Entry(cont).State = EntityState.Deleted;
            tstDb.Entry(phys).State = EntityState.Deleted;
            int Retval = tstDb.SaveChanges();

            return(Retval);
        }