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"); } } }
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; } } }