[longomatch] Return default added item



commit da6ddb09679aa675d4c6adc5e31fe17f2206c4ae
Author: Andoni Morales Alastruey <ylatuya gmail com>
Date:   Thu Mar 20 17:28:02 2014 +0100

    Return default added item

 LongoMatch.Core/Interfaces/ITemplates.cs           |    2 +-
 .../Store/Templates/CategoriesTemplate.cs          |    3 +-
 .../Store/Templates/SubCategoryTemplate.cs         |    2 +-
 LongoMatch.Core/Store/Templates/TeamTemplate.cs    |   22 ++++++++++---------
 4 files changed, 16 insertions(+), 13 deletions(-)
---
diff --git a/LongoMatch.Core/Interfaces/ITemplates.cs b/LongoMatch.Core/Interfaces/ITemplates.cs
index 3f0780d..a6d17c9 100644
--- a/LongoMatch.Core/Interfaces/ITemplates.cs
+++ b/LongoMatch.Core/Interfaces/ITemplates.cs
@@ -29,7 +29,7 @@ namespace LongoMatch.Interfaces
        }
        
        public interface ITemplate<T>: ITemplate, IList<T> {
-               void AddDefaultItem (int index);
+               T AddDefaultItem (int index);
        }
        
        public interface ITemplateProvider
diff --git a/LongoMatch.Core/Store/Templates/CategoriesTemplate.cs 
b/LongoMatch.Core/Store/Templates/CategoriesTemplate.cs
index c5efe27..3ec13d9 100644
--- a/LongoMatch.Core/Store/Templates/CategoriesTemplate.cs
+++ b/LongoMatch.Core/Store/Templates/CategoriesTemplate.cs
@@ -170,7 +170,7 @@ namespace LongoMatch.Store.Templates
                        cat.SubCategories.Add(visitorplayers);
                }       
                
-               public void AddDefaultItem (int index) {
+               public Category AddDefaultItem (int index) {
                        Color c = Color.FromArgb(255, 0, 0);
                        HotKey h = new HotKey();
                        
@@ -186,6 +186,7 @@ namespace LongoMatch.Store.Templates
                        };
                        AddDefaultSubcategories(cat);
                        Insert(index, cat);
+                       return cat;
                }
 
                public static Categories Load(string filePath) {
diff --git a/LongoMatch.Core/Store/Templates/SubCategoryTemplate.cs 
b/LongoMatch.Core/Store/Templates/SubCategoryTemplate.cs
index 465bfdc..9f65bbe 100644
--- a/LongoMatch.Core/Store/Templates/SubCategoryTemplate.cs
+++ b/LongoMatch.Core/Store/Templates/SubCategoryTemplate.cs
@@ -38,7 +38,7 @@ namespace LongoMatch.Store.Templates
                        get;
                        set;
                }
-               public void AddDefaultItem (int index) {
+               public string AddDefaultItem (int index) {
                        throw new Exception("Not implemented yet");
                }
 
diff --git a/LongoMatch.Core/Store/Templates/TeamTemplate.cs b/LongoMatch.Core/Store/Templates/TeamTemplate.cs
index ec6980a..bdd9ef4 100644
--- a/LongoMatch.Core/Store/Templates/TeamTemplate.cs
+++ b/LongoMatch.Core/Store/Templates/TeamTemplate.cs
@@ -78,16 +78,18 @@ namespace LongoMatch.Store.Templates
                        SerializableObject.Save(this, filePath);
                }
                
-               public void AddDefaultItem (int i) {
-                       Insert(i, new Player {
-                                       Name = "Player " + (i+1).ToString(),
-                                       Birthday = new DateTime(),
-                                       Height = 1.80f,
-                                       Weight = 80,
-                                       Number = i+1,
-                                       Position = "",
-                                       Photo = null,
-                                       Playing = true,});
+               public Player AddDefaultItem (int i) {
+                       Player p = new Player {
+                               Name = "Player " + (i+1).ToString(),
+                               Birthday = new DateTime(),
+                               Height = 1.80f,
+                               Weight = 80,
+                               Number = i+1,
+                               Position = "",
+                               Photo = null,
+                               Playing = true,};
+                       Insert (i, p);
+                       return p;
                }
 
                public static TeamTemplate Load(string filePath) {


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