コード例 #1
0
        private void LoadTvShowsList()
        {
            var orderedChannelRepo = new BaseRepository <OrderChannel>();
            var orderedChannels    = orderedChannelRepo.Get(ch => ch.User.Id == CurrentUserId).ToList();

            var showByDateAndChannels = new List <TvShow>();

            foreach (var chan in orderedChannels)
            {
                var showsChannel = new BaseRepository <TvShow>(orderedChannelRepo.ContextDb)
                                   .Get(
                    show => show.CodeOriginalChannel == chan.Channel.OriginalId).ToList()
                                   .FindAll(show => (int)show.Date.DayOfWeek == GetSelectedDay());
                showByDateAndChannels.AddRange(showsChannel);
            }

            ControlForShows?.Dispose();
            ControlForShows = new UcShowsList(CurrentUserId);
            ControlForShows.LoadShows(showByDateAndChannels);
            tabControl_Shows.SelectedTab.Controls.Add(ControlForShows);
        }
コード例 #2
0
        private void cbCheckAllChannels_CheckedChanged(object sender, EventArgs e)
        {
            if (cbCheckAllChannels.Checked)
            {
                lvChannelsList.BeginUpdate();
                for (var i = 0; i < lvChannelsList.Items.Count; i++)
                {
                    lvChannelsList.Items[i].Checked = true;
                }
                lvChannelsList.EndUpdate();

                var orderRepo      = new BaseRepository <Order>();
                var tvShowsRepo    = new BaseRepository <TvShow>(orderRepo.ContextDb);
                var channelsRepo   = new BaseRepository <Channel>(orderRepo.ContextDb);
                var ordChannelRepo = new BaseRepository <OrderChannel>(orderRepo.ContextDb);
                var user           = new BaseRepository <User>(orderRepo.ContextDb).Get(u => u.Id == CurrentUserId).FirstOrDefault();

                ordChannelRepo.Clear(CurrentUserId);

                var orderAllChann = channelsRepo.GetAll().ToList();
                var list          = orderAllChann.Select(channel => new OrderChannel
                {
                    Channel = channel, User = user
                }).ToList();

                ordChannelRepo.AddRange(list);

                var showByDateAndChannels = new List <TvShow>();
                foreach (var show in tvShowsRepo.GetAll())
                {
                    if ((int)show.Date.DayOfWeek == GetSelectedDay()
                        /*&& Math.Abs(x.Date.Day - DateTime.Now.Day) < 7*/)
                    {
                        showByDateAndChannels.Add(show);
                    }
                }

                ControlForShows?.Dispose();
                ControlForShows = new UcShowsList(CurrentUserId);
                ControlForShows.LoadShows(showByDateAndChannels);
                tabControl_Shows.SelectedTab.Controls.Add(ControlForShows);
            }
            else if (!cbCheckAllChannels.Checked)
            {
                //-------------------------------------------------------
                lvChannelsList.Items.Clear();

                var userSchRepo        = new BaseRepository <UserSchedule>();
                var deleteScheduleList = new List <UserSchedule>();
                //deleteSchedule = userSchRepo.Get(x => x.TvShow.Channel.OrderChannel. .User.Orders.FirstOrDefault(o => o.Id == CurrentOrderId).Id == CurrentOrderId).ToList();

                //-------------------------------------------------------

                var orderedChannRepo = new BaseRepository <OrderChannel>(userSchRepo.ContextDb);
                var deleteOrdChann   = orderedChannRepo.Get(x => x.Order == null &&
                                                            x.User.Id == CurrentUserId).ToList();

                foreach (var sched in userSchRepo.Get(uSch => uSch.User.Id == CurrentUserId).ToList())
                {
                    if (deleteOrdChann.Any(doch => doch.Channel.OriginalId == sched.TvShow.CodeOriginalChannel))
                    {
                        deleteScheduleList.Add(sched);
                    }
                }

                userSchRepo.RemoveRange(deleteScheduleList);
                orderedChannRepo.RemoveRange(deleteOrdChann);

                //-------------------------------------------------------
                LoadAllChannelsList();
                //-------------------------------------------------------

                ControlForShows?.Dispose();
                ControlForShows = new UcShowsList(CurrentUserId);
                tabControl_Shows.SelectedTab.Controls.Add(ControlForShows);
            }
        }