public int AssociateProductToVendor(IntegrationVendorProduct input) { using (var dc = new VendorDataContext(_connectionString)) { var maxId = dc.IntegrationVendorProducts.Max(x => x.IntegrationVendorProductId); input.IntegrationVendorProductId = maxId + 1; dc.IntegrationVendorProducts.InsertOnSubmit(input); dc.SubmitChanges(); } return(input.IntegrationVendorProductId); }
public void SaveVendorProduct(IntegrationVendorProduct vendorProduct) { using (var dc = new VendorDataContext(_connectionString)) { var dbVendorProduct = dc.IntegrationVendorProducts.FirstOrDefault(x => x.IntegrationVendorProductId == vendorProduct.IntegrationVendorProductId); if (dbVendorProduct != null) { dbVendorProduct.IntegrationHelperFQN = vendorProduct.IntegrationHelperFQN; dbVendorProduct.SimulatorURL = vendorProduct.SimulatorURL; } else { vendorProduct.IntegrationVendorProductId = dc.IntegrationVendorProducts.Max(x => x.IntegrationVendorProductId); dc.IntegrationVendorProducts.InsertOnSubmit(vendorProduct); } dc.SubmitChanges(); } }