public void StartAddService() { var inputDialoge = new dlgInput { inputLabel = "New Service Name", inputId = _vm.MaxServiceId() }; inputDialoge.ShowDialog(); if (string.IsNullOrEmpty(inputDialoge.inputValue)) { return; } var newServiceType = new IntegrationServiceType { IntegrationServiceTypeId = inputDialoge.inputId, Name = inputDialoge.inputValue, Descr = inputDialoge.inputValue, IsActive = true, CreatedBy = -1, ModifiedBy = -1, ModifiedDate = DateTime.UtcNow, }; _vm.AddService(newServiceType); var newServiceNode = new TreeNode { Text = $"{newServiceType.IntegrationServiceTypeId}-{newServiceType.Name}", ImageKey = "blank.png", SelectedImageKey = "blank.png", Tag = newServiceType, ToolTipText = MakeToolTip(newServiceType), }; tvServices.Nodes.Insert(tvServices.Nodes.Count - 1, newServiceNode); }
public int AddService(IntegrationServiceType input) { using (var dc = new VendorDataContext(_connectionString)) { dc.IntegrationServiceTypes.InsertOnSubmit(input); dc.SubmitChanges(); } return(input.IntegrationServiceTypeId); }
public void SaveService(IntegrationServiceType service) { using (var dc = new VendorDataContext(_connectionString)) { var dbService = dc.IntegrationServiceTypes.FirstOrDefault(x => x.IntegrationServiceTypeId == service.IntegrationServiceTypeId); if (dbService != null) { dbService.Name = service.Name; dbService.Descr = service.Descr; } dc.SubmitChanges(); } }
public void DeleteService(IntegrationServiceType input) { using (var dc = new VendorDataContext(_connectionString)) { var toDelete = dc.IntegrationServiceTypes.Where(x => x.IntegrationServiceTypeId == input.IntegrationServiceTypeId); var toDeleteProducts = dc.IntegrationProducts.Where(x => x.IntegrationServiceTypeId == input.IntegrationServiceTypeId); var toDeleteVendorProduct = dc.IntegrationVendorProducts.Where(x => toDeleteProducts.Select(a => a.IntegrationProductId).Contains(x.IntegrationProductId.Value)); dc.IntegrationVendorProducts.DeleteAllOnSubmit(toDeleteVendorProduct); dc.IntegrationProducts.DeleteAllOnSubmit(toDeleteProducts); dc.IntegrationServiceTypes.DeleteAllOnSubmit(toDelete); dc.SubmitChanges(); } }
private string MakeToolTip(IntegrationServiceType input) { return ($"IntegrationServiceTypeId = {input.IntegrationServiceTypeId} for ({input.Descr}) located at [{input.GetType().ToString().Split('.').Last()}] table"); }