[longomatch] Fix overwritting teams with the same name



commit f57bc5b59c640899c061881fb1afa3fd13255201
Author: Andoni Morales Alastruey <ylatuya gmail com>
Date:   Tue Feb 24 12:54:58 2015 +0100

    Fix overwritting teams with the same name

 LongoMatch.GUI/Gui/Panel/TeamsTemplatesPanel.cs |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)
---
diff --git a/LongoMatch.GUI/Gui/Panel/TeamsTemplatesPanel.cs b/LongoMatch.GUI/Gui/Panel/TeamsTemplatesPanel.cs
index 78c0a83..1b4ec36 100644
--- a/LongoMatch.GUI/Gui/Panel/TeamsTemplatesPanel.cs
+++ b/LongoMatch.GUI/Gui/Panel/TeamsTemplatesPanel.cs
@@ -272,6 +272,7 @@ namespace LongoMatch.Gui.Panel
                void HandleNewTeamClicked (object sender, EventArgs e)
                {
                        bool create = false;
+                       bool force = false;
                        
                        EntryDialog dialog = new EntryDialog ();
                        dialog.TransientFor = (Gtk.Window)this.Toplevel;
@@ -291,6 +292,7 @@ namespace LongoMatch.Gui.Panel
                                                "Do you want to overwrite it?");
                                        if (MessagesHelpers.QuestionMessage (this, msg)) {
                                                create = true;
+                                               force = true;
                                                break;
                                        }
                                } else {
@@ -300,6 +302,13 @@ namespace LongoMatch.Gui.Panel
                        }
                        
                        if (create) {
+                               if (force) {
+                                       try {
+                                               provider.Delete (dialog.Text);
+                                       } catch (Exception ex){
+                                               Log.Exception (ex);
+                                       }
+                               }
                                if (dialog.SelectedTemplate != null) {
                                        provider.Copy (dialog.SelectedTemplate, dialog.Text);
                                } else {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]