From d1d38947324d9960239a5486df8eace985aef9d9 Mon Sep 17 00:00:00 2001 From: amazing-username Date: Wed, 5 Jun 2019 16:09:00 -0700 Subject: [PATCH] Left TODO for implementing the Repeat table. #35 --- Mear/Mear/Models/MusicControls.cs | 19 +++++ .../Repositories/Database/DBMusicControls.cs | 73 +++++++++++++++++++ 2 files changed, 92 insertions(+) create mode 100644 Mear/Mear/Models/MusicControls.cs create mode 100644 Mear/Mear/Repositories/Database/DBMusicControls.cs diff --git a/Mear/Mear/Models/MusicControls.cs b/Mear/Mear/Models/MusicControls.cs new file mode 100644 index 0000000..8c671c1 --- /dev/null +++ b/Mear/Mear/Models/MusicControls.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.Runtime.Serialization; +using System.Text; + +using SQLite; + +namespace Mear.Models +{ + [DataContract] + [Table("MusicControls")] + public class MusicControls + { + [PrimaryKey, Column("Id"), AutoIncrement] + public int Id { get; set; } + public bool ShuffleOn { get; set; } = false; + public bool RepeatOn { get; set; } = false; + } +} diff --git a/Mear/Mear/Repositories/Database/DBMusicControls.cs b/Mear/Mear/Repositories/Database/DBMusicControls.cs new file mode 100644 index 0000000..9b41b6c --- /dev/null +++ b/Mear/Mear/Repositories/Database/DBMusicControls.cs @@ -0,0 +1,73 @@ +using System; +using System.Collections.Generic; +using System.Text; + +using Mear.Models; + +namespace Mear.Repositories.Database +{ + // TODO: Implement the database functionality #35 + public class DBMusicControls : DBRepository + { + #region Fields + #endregion + + + #region Properties + #endregion + + + #region Constructors + public DBMusicControls() + { + Initialize(); + } + #endregion + + + #region Methods + public bool IsShuffleOn() + { + try + { + if (DoesTableExist("MusicControls")) + { + bool? shuffle = _Db.Table().First().ShuffleOn; + + if (shuffle != null) + { + return shuffle.Value; ; + } + } + } + catch (Exception ex) + { + var msg = ex.Message; + } + + return false; + } + public bool IsRepeatOn() + { + try + { + if (DoesTableExist("MusicControls")) + { + bool? repeat = _Db.Table().First().RepeatOn; + + if (repeat != null) + { + return repeat.Value; + } + } + } + catch (Exception ex) + { + var msg = ex.Message; + } + + return false; + } + #endregion + } +}