tasque r214 - in trunk: . src/Backends/Hiveminder



Author: jjohnny
Date: Sun Feb  8 18:22:57 2009
New Revision: 214
URL: http://svn.gnome.org/viewvc/tasque?rev=214&view=rev

Log:
Hiveminder : Create, Delete & Save notes added.

Modified:
   trunk/ChangeLog
   trunk/src/Backends/Hiveminder/HmNote.cs
   trunk/src/Backends/Hiveminder/HmTask.cs

Modified: trunk/src/Backends/Hiveminder/HmNote.cs
==============================================================================
--- trunk/src/Backends/Hiveminder/HmNote.cs	(original)
+++ trunk/src/Backends/Hiveminder/HmNote.cs	Sun Feb  8 18:22:57 2009
@@ -29,21 +29,18 @@
 {
        public class HmNote : INote
        {
-	       private string text;
+	       private Hiveminder.Task task;
 
-	       public HmNote (string text)
+	       public HmNote (Hiveminder.Task task)
 	       {
-		       this.text = text;
+		       this.task = task;
 	       }
 
-			public string Text
-			{
-				get { return this.text; }
+	       public string Text
+	       {
+		       get { return this.task.Description; }
                 
-				set {
-					this.text = value;
-				}
-			}
-
+		       set { this.task.Description = value; }
+	       }
        }
 }

Modified: trunk/src/Backends/Hiveminder/HmTask.cs
==============================================================================
--- trunk/src/Backends/Hiveminder/HmTask.cs	(original)
+++ trunk/src/Backends/Hiveminder/HmTask.cs	Sun Feb  8 18:22:57 2009
@@ -196,12 +196,12 @@
 		{
 			this.task = task;
 			this.backend = hmBackend;
+
 			//Add Description as note.
-			this.notes = null;
-			if (!string.IsNullOrEmpty (this.task.Description)) {
-				this.notes = new List<INote>();
-				notes.Add (new HmNote (this.task.Description));
-			}
+			this.notes = new List<INote>();
+
+			if (!string.IsNullOrEmpty (this.task.Description)) 
+				notes.Add (new HmNote (this.task));
 		}
 		
 		#endregion
@@ -248,8 +248,17 @@
 		/// </param>
 		public override INote CreateNote(string text)
 		{
-			Logger.Info ("CreateNote : Not implemented");
-			return null;
+			Logger.Debug ("CreateNote : " + text);
+
+			HmNote hmNote = new HmNote (this.task);
+			hmNote.Text = text;
+
+			notes.Clear ();
+			notes.Add (hmNote);
+
+			this.backend.UpdateTask (this);
+
+			return hmNote;
 		}
 		
 		/// <summary>
@@ -260,19 +269,38 @@
 		/// </param>
 		public override void DeleteNote(INote note)
 		{
-			Logger.Info ("Not implemented");
+		       Logger.Debug ("DeleteNote : " + note.Text);
+
+		       foreach(HmNote hmNote in notes) {
+			       if(string.Equals (hmNote.Text, note.Text)) {
+				       hmNote.Text = null;
+				       notes.Remove(hmNote);
+				       break;
+			       }
+		       }
+
+		       this.backend.UpdateTask (this);
 		}		
 
 		/// <summary>
-		/// Deletes a note from a task
+		/// Saves a note in a task
 		/// </summary>
 		/// <param name="note">
 		/// A <see cref="INote"/>
 		/// </param>
 		public override void SaveNote(INote note)
 		{		
-			Logger.Info ("Not implemented");
+			Logger.Debug ("SaveNote : " + note.Text);
+
+			HmNote hmNote = new HmNote (this.task);
+			hmNote.Text = note.Text;
+
+			notes.Clear ();
+			notes.Add (hmNote);
+
+			this.backend.UpdateTask (this);
 		}		
+
 		public int CompareTo (ITask task)
 		{
 			bool isSameDate = true;



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