public static void delete(Record record) { Records history = RecordsManager.GetHistory(); history.records = history.records.FindAll((obj) => obj.id != record.id); PlayerPrefs.SetString("history", JsonUtility.ToJson(history)); }
internal static Records GetReverseHistorySortedByDay() { Records history = RecordsManager.GetHistory(); history.records.Sort(); return(history); }
public static void save(Record record) { if (record.id == 0) { record.id = GetNextId(); } Records history = RecordsManager.GetHistory(); history.records.Add(record); PlayerPrefs.SetString("history", JsonUtility.ToJson(history)); }
public static void update(Record timeRecord) { Records history = RecordsManager.GetHistory(); List <Record> records = history.records.ConvertAll((Record input) => { int id = input.id; if (id == timeRecord.id) { return(timeRecord); } return(input); }); history.records = records; RecordsManager.updateHistory(history); }
internal static Record getLongestSleepRecord() { Record longestSleep = null; Records records = RecordsManager.GetHistory(); foreach (Record record in records.records) { if (longestSleep == null) { longestSleep = record; } else if (getTimeSpan(record) > getTimeSpan(longestSleep)) { longestSleep = record; } } return(longestSleep); }
public static Record getById(int id) { return(RecordsManager.GetHistory().records.Find((obj) => obj.id == id)); }