public void DeleteCommand(object data, jQueryEvent e) { Utility.ConfirmDialog(ResourceStrings.ConfirmDeleteConnection, delegate(){ string id = e.Target.ParentNode.GetAttribute("rowId").ToString(); OrganizationServiceProxy.BeginDelete(Connection.LogicalName, new Guid(id), delegate(object state) { try { OrganizationServiceProxy.EndDelete(state); foreach (Entity connection in Connections.Data) { if (connection.Id == id) { Connections.RemoveItem(connection); break; } } Connections.Refresh(); } catch (Exception ex) { ErrorMessage.SetValue(ex.Message); } }); }, null); }
public Action DeleteCommand() { if (_deleteCommand == null) { _deleteCommand = delegate() { List <int> selectedRows = DataViewBase.RangesToRows(Lines.GetSelectedRows()); if (selectedRows.Count == 0) { return; } bool confirmed = Script.Confirm(String.Format("Are you sure that you want to delete the {0} quote lines in the Grid?", selectedRows.Count)); if (!confirmed) { return; } List <Entity> itemsToRemove = new List <Entity>(); foreach (int row in selectedRows) { itemsToRemove.Add((Entity)Lines.GetItem(row)); } foreach (Entity item in itemsToRemove) { item.EntityState = EntityStates.Deleted; Lines.RemoveItem(item); } Lines.Refresh(); }; } return(_deleteCommand); }