public void AddCatalog(Model.Catalog catalog)
 {
     using (LibDataContext lib = new LibDataContext(ConnectionString)) {
         ValidationResult authorValidation = varcharValidator.Validate(catalog.Author, null);
         if (!authorValidation.IsValid)
         {
             return;
         }
         ValidationResult titleValidation = varcharValidator.Validate(catalog.Title, null);
         if (!titleValidation.IsValid)
         {
             return;
         }
         lib.Catalogs.InsertOnSubmit(new Catalog(catalog.CatalogId, catalog.Author, catalog.Title));
         lib.SubmitChanges();
     }
 }
 public void UpdateCatalog(Model.Catalog catalog)
 {
     using (LibDataContext lib = new LibDataContext(ConnectionString)) {
         ValidationResult authorValidation = varcharValidator.Validate(catalog.Author, null);
         if (!authorValidation.IsValid)
         {
             return;
         }
         ValidationResult titleValidation = varcharValidator.Validate(catalog.Title, null);
         if (!titleValidation.IsValid)
         {
             return;
         }
         Catalog catalogEntity = lib.Catalogs.Where(c => c.Id == catalog.CatalogId).FirstOrDefault();
         catalogEntity.Author = catalog.Author;
         catalogEntity.Title  = catalog.Title;
         lib.SubmitChanges();
     }
 }