Example #1
0
        /// <summary>
        /// Converts the current object to an instance of DBEntryToSave which
        /// is getting saved in the database.
        /// </summary>
        /// <returns>This object as a DBEntryToSave instance</returns>
        public DBEntryToSave ConvertToDBEntryToSave()
        {
            DBEntryToSave entryToSave = new DBEntryToSave
            {
                DateTime = this.Date,
                TrainingsDataAsString = JsonConvert.SerializeObject(this.TrainingsData)
            };

            return(entryToSave);
        }
Example #2
0
        /// <summary>
        /// Parses the given instance of type DBEntryToSave to an instance to DBEntry.
        /// </summary>
        /// <param name="entry">The given entry, which needs to get parsed</param>
        /// <returns>A </returns>
        public static DBEntry ParseDbEntry(DBEntryToSave entry)
        {
            Dictionary <string, int> trainingsData = JsonConvert.DeserializeObject <Dictionary <string, int> >(entry.TrainingsDataAsString);
            DBEntry result = new DBEntry
            {
                Date          = entry.DateTime,
                TrainingsData = trainingsData
            };

            return(result);
        }