/// <summary> /// Adds the new drink record to the user model /// </summary> /// <param name="date">Date.</param> /// <param name="volume">Volume.</param> public void addNewDrinkRecord(DateTime date, double volume) { DrinkRecordModel drink = new DrinkRecordModel (); drink.date = date; drink.volume = volume; addNewDrinkRecord (drink); }
/// <summary> /// Adds the new drink record to the user model /// </summary> /// <param name="drink">Drink.</param> public void addNewDrinkRecord(DrinkRecordModel drink) { if (drink == null) return; if (_userDrinkModel == null) _userDrinkModel = new UserDrinkModel(); _userDrinkModel.listRecords.Add (drink); saveNewDrink (drink); }
/// <summary> /// Saves the new drink in the file /// </summary> /// <param name="drink">Drink.</param> protected void saveNewDrink(DrinkRecordModel drink) { if (!File.Exists (saveFile)) File.Create (saveFile); using (TextWriter writer = File.AppendText(saveFile)) { writer.WriteLine(drink.ToString()); } }
/// <summary> /// Parses a line of the database and add the data to the drink model /// </summary> /// <param name="line">Line.</param> protected void parseLine(string line) { if (string.IsNullOrEmpty (line)) return; var parsedLine = line.Split ('\t'); if (parsedLine.Length != DrinkRecordModel.length) return; DrinkRecordModel drink = new DrinkRecordModel (parsedLine [0], parsedLine [1]); _userDrinkModel.listRecords.Add (drink); }