コード例 #1
0
 public void UpdateHeight(int heightId, Height height)
 {
     using (var dataContext = new eHealthCareEntities())
     {
         try
         {
             var heightToUpdate = GetHeightById(height.PatientId, heightId);
             if (heightToUpdate != null)
             {
                 heightToUpdate.Date = height.Date;
                 heightToUpdate.HeightFeet = height.HeightFeet;
                 heightToUpdate.HeightInch = height.HeightInch;
                 dataContext.Heights.Attach(heightToUpdate);
                 dataContext.Entry(heightToUpdate).State = EntityState.Modified;
                 dataContext.SaveChanges();
             }
         }
         catch (DbEntityValidationException ex)
         {
             throw new Exception(ex.EntityValidationErrors.GetValidationErrors());
         }
         catch
         {
             throw;
         }
     }
 }
コード例 #2
0
 public void SaveHeight(Height height)
 {
     using (var dataContext = new eHealthCareEntities())
     {
         try
         {
             dataContext.Heights.Add(height);
             dataContext.SaveChanges();
         }
         catch (DbEntityValidationException ex)
         {
             throw new Exception(ex.EntityValidationErrors.GetValidationErrors());
         }
         catch
         {
             throw;
         }
     }
 }