예제 #1
0
 public static void AddCategory(string name, IMessenger messenger)
 {
     using (TimeTrackingDBEntities context = new TimeTrackingDBEntities())
     {
         context.Categories.Add(new Category {
             Name = name
         });
         context.SaveChanges();
     }
     messenger.Send("Update");
 }
예제 #2
0
 public static void AddActivity(string categoryString, string name, IMessenger messenger)
 {
     using (TimeTrackingDBEntities context = new TimeTrackingDBEntities())
     {
         Category category = context.Categories.FirstOrDefault(c => c.Name == categoryString);
         category.Activities.Add(new Activity
         {
             Name = name
         });
         context.SaveChanges();
     }
     messenger.Send("Update");
 }
예제 #3
0
 public static void AddEntry(string activityString, string comment, string duration, DateTime date, IMessenger messenger)
 {
     using (TimeTrackingDBEntities context = new TimeTrackingDBEntities())
     {
         Activity activity = context.Activities.FirstOrDefault(c => c.Name == activityString);
         activity.TimeEntries.Add(new TimeEntry
         {
             Comment      = comment,
             Duration     = double.Parse(duration),
             CreationDate = DateTime.Now,
             Date         = date
         });
         context.SaveChanges();
     }
     messenger.Send("Update");
 }