/// <summary> /// Update this Autoplay's options with those in the new Autoplay /// </summary> /// <param name="newAutoplay"></param> public void UpdateOptions(Autoplay newAutoplay) { bool optionsChanged = (newAutoplay.Spread != Spread) || (newAutoplay.Target != Target) || (newAutoplay.Weight != Weight) || (newAutoplay.FastSpreadLimit != FastSpreadLimit); Spread = newAutoplay.Spread; Target = newAutoplay.Target; Weight = newAutoplay.Weight; FastSpreadLimit = newAutoplay.FastSpreadLimit; if (optionsChanged == true) { // Update the record. No need to wait. DbAccess.UpdateAsync(this); } }
/// <summary> /// Get the Autoplay record associated with the specified library. /// If there is no such record then create one /// </summary> /// <param name="libraryId"></param> /// <returns></returns> public static async Task <Autoplay> GetAutoplayAsync(int libraryId) { Autoplay autoPlay = AutoplayCollection.SingleOrDefault(auto => auto.LibraryId == libraryId); if (autoPlay == null) { autoPlay = new Autoplay() { LibraryId = libraryId }; // Need to wait for thus so that it's Id gets set await DbAccess.InsertAsync(autoPlay); } return(autoPlay); }