public static int GetForeignKeyType(BaseDatabaseField baseField) { Type classType = baseField.GetType(); int foreignKeyType = -1; if (ClassTypeForeignKeyTypeMapper.ContainsKey(classType)) { foreignKeyType = ClassTypeForeignKeyTypeMapper[classType]; } else { throw new Exception("ForeignKeyType not defined"); } return(foreignKeyType); }
protected void MarkForDelete <T>(string category, BaseDatabaseField model, Func <SQLQueryResult <T> > postActionDelete, Action postActionUpdate) where T : BaseDatabaseField { if (model == null || model.Id < 0) { new NotificationWindow("Fehler!", "Es sind kein " + category + " ausgewählt um zu löschen", null, NotificationWindow.MessageType.Waring).Show(); return; } var msg = category + ": \n'" + model.GetFullName() + "' \nlöschen?"; AskForceToDelete(msg, category + " löschen", () => { try { var titel = string.Format("{1} : {0}", model.GetFullName(), category); var result = postActionDelete(); if (result.Records > 0) { if (postActionUpdate != null) { postActionUpdate(); } msg = category + " wurde gelöscht."; new NotificationWindow(titel, msg).Show(); } else { msg = category + " konnte nicht gelöscht werden."; new NotificationWindow("Fehler!", msg).Show(); } } catch (Exception exception) { Console.WriteLine(exception); msg = category + " konnte nicht gelöscht werden."; new NotificationWindow("Fehler!", exception.ToString(), null, NotificationWindow.MessageType.Error) .Show(); } }); }