Example #1
0
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            using (IdeasContext ctx = new IdeasContext(IdeasContext.ConnectionString))
            {
                ctx.CreateIfNotExists();

                DeleteCatList.ItemsSource = ctx.Categories.Where(d => d.Isdefault == 0).Where(d => d.Ideas.Count == 0).ToList();

            }
        }
Example #2
0
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            using (IdeasContext ctx = new IdeasContext(IdeasContext.ConnectionString))
            {
                ctx.CreateIfNotExists();

                this.lpkCategories.ItemsSource = ctx.Categories.OrderBy(d => d.Name).Select(d => d.Name).ToList();
            }

        }
Example #3
0
        private void ApplicationBarIconButton_Click(object sender, EventArgs e)
        {
            using (IdeasContext ctx = new IdeasContext(IdeasContext.ConnectionString))
            {
                ctx.CreateIfNotExists();

                var bla = (from p in ctx.Ideas where p.Id == IdeaId select p).Single();

                ctx.Ideas.DeleteOnSubmit(bla);
                ctx.SubmitChanges();

                NavigationService.GoBack();
            }
        }
Example #4
0
        private void DeleteButton_Click(object sender, RoutedEventArgs e)
        {
            using (IdeasContext ctx = new IdeasContext(IdeasContext.ConnectionString))
            {
                Button _button = (Button)sender;

                var bla = (from p in ctx.Categories where p.Id == (int)_button.Tag select p).Single();

                ctx.Categories.DeleteOnSubmit(bla);
                ctx.SubmitChanges();

                DeleteCatList.ItemsSource = ctx.Categories.Where(d => d.Isdefault == 0).Where(d => d.Ideas.Count == 0).ToList();
            }
        }
Example #5
0
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            if (NavigationContext.QueryString.ContainsKey("SelectedCat"))
            {
                CatId = Convert.ToInt16(NavigationContext.QueryString["SelectedCat"]);
            }

            using (IdeasContext ctx = new IdeasContext(IdeasContext.ConnectionString))
            {
                ctx.CreateIfNotExists();

                this.IdeasList.ItemsSource = ctx.Ideas.Where(d => d.Cat_id == CatId).OrderBy(d => d.Title).ToList();

                PageTitle.DataContext = (from p in ctx.Categories where p.Id == CatId select p.Name).Single();
            }

        }
Example #6
0
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            if (NavigationContext.QueryString.ContainsKey("SelectedIdea"))
            {
                IdeaId = Convert.ToInt16(NavigationContext.QueryString["SelectedIdea"]);
            }

            using (IdeasContext ctx = new IdeasContext(IdeasContext.ConnectionString))
            {
                ctx.CreateIfNotExists();

                PageTitle.DataContext = (from p in ctx.Ideas where p.Id == IdeaId select p.Title).Single();
                IdeaContent.DataContext = (from p in ctx.Ideas where p.Id == IdeaId select p.Content).Single();

            }

        }
Example #7
0
        private void CreateCategory()
        {
            if (NewCatName.Text.Length > 250)
            {
                MessageBox.Show("Category name is too long!");
            }
            else if (NewCatName.Text != "")
            {
                using (IdeasContext ctx = new IdeasContext(IdeasContext.ConnectionString))
                {
                    ctx.CreateIfNotExists();

                    var category = new Categories() { Name = NewCatName.Text };

                    ctx.Categories.InsertOnSubmit(category);
                    ctx.SubmitChanges();

                    NavigationService.GoBack();

                }
            }
        }
Example #8
0
        private void CreateIdea()
        {

            if (IdeaTitle.Text.Length > 250)
            {
                MessageBox.Show("Idea title is too long!");
            }
            else if (IdeaContent.Text.Length > 3990)
            {
                MessageBox.Show("Sorry, idea content is too long!");
            }
            else if (IdeaTitle.Text.Length > 0 && IdeaContent.Text.Length > 0)
            {
                using (IdeasContext ctx = new IdeasContext(IdeasContext.ConnectionString))
                {
                    ctx.CreateIfNotExists();

                    int CatId = (from p in ctx.Categories where p.Name == lpkCategories.SelectedItem.ToString() select p.Id).Single();

                    var idea = new Ideas() { Title = IdeaTitle.Text, Cat_id = CatId, Content = IdeaContent.Text };

                    ctx.Ideas.InsertOnSubmit(idea);
                    ctx.SubmitChanges();

                    NavigationService.GoBack();
                }
            }
        }