Ejemplo n.º 1
0
        public void Show(int p_viewIndex, object p_dataContext, bool p_isModal, Action <bool?> p_closeAction)
        {
            Window control = null;

            switch (p_viewIndex)
            {
            case 0:
                control = new EditView();
                break;

            case 1:
                control = new ShowListView();
                break;

            default:
                throw new ArgumentOutOfRangeException("p_viewIndex", "Такого индекса View не существует");
            }
            if (control != null)
            {
                Window wnd = new Window();
                wnd.SizeToContent   = SizeToContent.WidthAndHeight;
                control.DataContext = p_dataContext;
                StackPanel sp = new StackPanel();
                sp.Children.Add(control);
                Button applyButton = new Button();
                applyButton.Content = "Принять";
                applyButton.Click  += (s, e) => { if (p_isModal)
                                                  {
                                                      wnd.DialogResult = true;
                                                  }
                                                  else
                                                  {
                                                      wnd.Close();
                                                  } };
                StackPanel buttonPanel = new StackPanel();
                buttonPanel.Orientation = Orientation.Horizontal;
                buttonPanel.Children.Add(applyButton);
                sp.Children.Add(buttonPanel);
                wnd.Content = sp;
                wnd.Closed += (s, e) => p_closeAction(wnd.DialogResult);
                if (p_isModal)
                {
                    Button cancelButton = new Button();
                    cancelButton.Content = "Отмена";
                    cancelButton.Click  += (s, e) => wnd.DialogResult = false;
                    buttonPanel.Children.Add(cancelButton);
                    wnd.ShowDialog();
                }
                else
                {
                    wnd.Show();
                }
            }
        }
Ejemplo n.º 2
0
        public ActionResult Index(string Season = null)
        {
            List <ShowModel>  shows      = context.Collection().ToList();
            List <ShowSeason> showSeason = showseasonContext.Collection().ToList();

            if (Season == null)
            {
                shows = context.Collection().ToList();
            }
            else
            {
                shows = context.Collection().Where(p => p.PremieredSeason == Season).ToList();
            }

            ShowListView model = new ShowListView();

            model.shows      = shows;
            model.showSeason = showSeason;
            return(View(model));
        }