예제 #1
0
 public void AddPublisher(publisher newPublisher)
 {
     using (var dbModel = new LMSDataModelEntities())
     {
         dbModel.publishers.AddObject(newPublisher);
         dbModel.ObjectStateManager.ChangeObjectState(newPublisher, System.Data.EntityState.Added);
         var savecount = dbModel.SaveChanges();
         if (savecount < 1)
         {
             throw new Exception("Fail to insert Publisher " + newPublisher.Name + " into DB");
         }
     }
 }
예제 #2
0
        private void Fixuppublisher(publisher previousValue)
        {
            if (previousValue != null && previousValue.books.Contains(this))
            {
                previousValue.books.Remove(this);
            }

            if (publisher != null)
            {
                if (!publisher.books.Contains(this))
                {
                    publisher.books.Add(this);
                }
                if (PublisherID != publisher.Id)
                {
                    PublisherID = publisher.Id;
                }
            }
        }