/// <summary>Adds new series to db & updates UI</summary> public void AddNewSeries(Series series) { bool existsExcludingId = db.Exists(s => s.Name == series.Name && s.Status == series.Status //s.Schedule.Season == series.Schedule.Season && //s.Schedule.Episode == series.Schedule.Episode ); if (existsExcludingId) { if (MessageBox.Show("Another item with this specifications already exists.\n" + "Do you still want to add a new one?", "Duplicated", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) { return; } } else if (db.Exists(s => s.Name == series.Name)) { if (MessageBox.Show("Another item with this name already exists.\n" + "Do you still want to add a new one?", "Duplicated", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) { return; } } int id = db.Add(series); series.Id = id; bindingSource.Add(series.AdaptSeries()); }
public SeriesDbTests() { db = new SeriesDb(); for (int i = 0; i < 20; i++) { var s = new Series { Name = $"Test{(i + rand(byte.MinValue, ushort.MaxValue))}{new string('*', 6)}", Status = TvSeriesLogsDb.Helper.SeenStatus.Seeing, Seasons = rand(1, 100), Schedule = null, Detail = null, }; db.Add(s); list.Add(s); } }