コード例 #1
0
        /// <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());
        }