/// <summary> /// Deletes an entry. /// </summary> /// <param name="id">The ID of the entry to delete.</param> public void DeleteEntry(int id) { //// Find the index of the entry that we need to delete. //int entryIndex = Data.Entries.FindIndex(e => e.Id == id); //if (entryIndex == -1) //{ // throw new Exception( // string.Format("Unable to find an entry with an ID of {0}", id)); //} //Data.Entries.RemoveAt(entryIndex); ConnectDb c = new ConnectDb(); c.DeleteEntry(id); }
/// <summary> /// Updates an entry. /// </summary> /// <param name="entry">The entry to update.</param> public void UpdateEntry(Entry entry) { //// Find the index of the entry that we need to update. //int entryIndex = Data.Entries.FindIndex(e => e.Id == entry.Id); //if (entryIndex == -1) //{ // throw new Exception( // string.Format("Unable to find an entry with an ID of {0}", entry.Id)); //} //Data.Entries[entryIndex] = entry; ConnectDb c = new ConnectDb(); c.UpdateEntry(entry); }
/// <summary> /// Returns a collection of entries. /// </summary> /// <returns>A list of entries.</returns> public List <Entry> GetEntries() { ConnectDb connectDb = new ConnectDb(); return(connectDb.GetListForIndex() .Join( Data.Activities, // The inner collection e => e.ActivityId, // The outer selector a => a.Id, // The inner selector (e, a) => // The result selector { e.Activity = a; // Set the entry's Activity property return e; // Return the entry } ) .OrderByDescending(e => e.Date) .ThenByDescending(e => e.Id) .ToList()); }
/// <summary> /// Returns a single entry for the provided ID. /// </summary> /// <param name="id">The ID for the entry to return.</param> /// <returns>An entry.</returns> public Entry GetEntry(int id) { ConnectDb c = new ConnectDb(); return(c.GetEntry(id)); }