Exemplo n.º 1
0
        public ActionResult Tegs(int?id_teg)
        {
            if (id_teg == null)
            {
                return(RedirectToAction("Index", "Home"));
            }

            DataBaseTegs          dataBaseTeg           = new DataBaseTegs();
            DataBaseArticles_Tegs dataBaseArticles_Tegs = new DataBaseArticles_Tegs();
            DataBaseArticles      dataBaseArticle       = new DataBaseArticles();
            DataBaseCategories    dataBaseCategory      = new DataBaseCategories();

            var id_articles = dataBaseArticles_Tegs.SelectArticles(id_teg);

            List <OneArticle> fullArticles = new List <OneArticle>();

            foreach (var id_article in id_articles)
            {
                OneArticle oneArticle = new OneArticle();

                var id_tegs = dataBaseArticles_Tegs.SelectTegs(id_article.Articles_Id);

                foreach (var teg in id_tegs)
                {
                    var tegs = dataBaseTeg.Select(teg.Tegs_Id);
                    oneArticle.Tegs.Add(tegs);
                }

                oneArticle.Article  = dataBaseArticle.Select(id_article.Articles_Id);
                oneArticle.Category = dataBaseCategory.Select(oneArticle.Article.Category_Id);
                fullArticles.Add(oneArticle);
            }

            return(View(fullArticles));
        }
Exemplo n.º 2
0
        private void OpenArticle_Click(object sender, RoutedEventArgs e)
        {
            OracleDbContext db             = new OracleDbContext();
            int             UserId         = CurrentUser.User.UserId;
            var             currentArticle = (ArticlesUser)((Button)sender).Tag;
            var             art            = db.Articles.FirstOrDefault(x => x.ArticleId == currentArticle.ArticleId_ArticlesUser);

            var currentPage = ((MainWindow)Application.Current.MainWindow).CurrentPage.Content;

            if (currentPage == null || (currentPage != null && currentPage.GetType().Name == "UserPage"))
            {
                OneArticle one = new OneArticle();
                one.Title.Text = art.Title;
                one.Text.Text  = art.Text;
                if (art.Image != null)
                {
                    one.Source.Source = Pima.ViewModel.Converter.ConvertByteArrayToImage(art.Image);
                }
                else
                {
                    one.Source.Visibility = Visibility.Collapsed;
                }
                (currentPage as UserPages.UserPage).CurrentPage.Navigate(one);
            }
        }
Exemplo n.º 3
0
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(RedirectToAction("Index", "Home"));
            }

            DataBaseArticles      dataBaseArticle       = new DataBaseArticles();
            DataBaseCategories    dataBaseCategory      = new DataBaseCategories();
            DataBaseArticles_Tegs dataBaseArticles_Tegs = new DataBaseArticles_Tegs();
            DataBaseTegs          dataBaseTeg           = new DataBaseTegs();

            OneArticle oneArticle = new OneArticle();

            oneArticle.Article    = dataBaseArticle.Select(id);
            oneArticle.Categories = new SelectList(dataBaseCategory.Select(), "Category_Id", "Name");
            oneArticle.Category   = dataBaseCategory.Select(oneArticle.Article.Category_Id);

            var id_tegs = dataBaseArticles_Tegs.SelectTegs(oneArticle.Article.Article_Id);

            foreach (var id_teg in id_tegs)
            {
                var teg = dataBaseTeg.Select(id_teg.Tegs_Id);
                oneArticle.Teg += teg.Name;
            }

            return(View(oneArticle));
        }
Exemplo n.º 4
0
        private List <OneArticle> GetArticles(List <Article> articles)
        {
            DataBaseArticles_Tegs dataBaseArticles_Tegs = new DataBaseArticles_Tegs();
            DataBaseTegs          dataBaseTegs          = new DataBaseTegs();
            DataBaseCategories    dataBaseCategories    = new DataBaseCategories();

            List <OneArticle> oneArticles = new List <OneArticle>();

            foreach (var a in articles)
            {
                OneArticle oneArticle = new OneArticle();
                oneArticle.Article  = a;
                oneArticle.Category = dataBaseCategories.Select(a.Category_Id);

                var id_teg = dataBaseArticles_Tegs.SelectTegs(a.Article_Id);

                foreach (var teg in id_teg)
                {
                    oneArticle.Tegs.Add(dataBaseTegs.Select(teg.Tegs_Id));
                }

                oneArticles.Add(oneArticle);
            }

            return(oneArticles);
        }
Exemplo n.º 5
0
        private List <OneArticle> GetArticles(List <Article> articles, string tegsModel)
        {
            DataBaseArticles_Tegs dataBaseArticles_Tegs = new DataBaseArticles_Tegs();
            DataBaseTegs          dataBaseTegs          = new DataBaseTegs();
            DataBaseCategories    dataBaseCategories    = new DataBaseCategories();

            string[] tegs = tegsModel.Split(new char[] { '#' }, StringSplitOptions.RemoveEmptyEntries);

            List <OneArticle> oneArticles = new List <OneArticle>();

            foreach (var a in articles)
            {
                bool       check      = false;
                OneArticle oneArticle = new OneArticle();
                var        id_teg     = dataBaseArticles_Tegs.SelectTegs(a.Article_Id);

                List <Teg> listTegs = new List <Teg>();

                foreach (var teg in id_teg)
                {
                    var getTegs = dataBaseTegs.Select(teg.Tegs_Id);
                    listTegs.Add(getTegs);

                    if (tegs.Contains(getTegs.Name.Substring(1)))
                    {
                        check = true;
                    }
                }

                if (check)
                {
                    oneArticle.Article  = a;
                    oneArticle.Category = dataBaseCategories.Select(a.Category_Id);
                    oneArticle.Tegs     = listTegs;
                }

                oneArticles.Add(oneArticle);
            }

            try
            {
                oneArticles.Reverse();
            }
            catch (Exception)
            {}

            return(oneArticles);
        }
Exemplo n.º 6
0
        public ActionResult Category(int?id_category, int?id_page)
        {
            DataBaseArticles   dataBaseArticle  = new DataBaseArticles();
            DataBaseCategories dataBaseCategory = new DataBaseCategories();

            var articles = dataBaseArticle.SelectTop10Category(Convert.ToInt32(id_page), Convert.ToInt32(id_category));
            var category = dataBaseCategory.Select(id_category);

            List <OneArticle> fullArticles = new List <OneArticle>();

            bool check = false;

            try
            {
                if (articles[articles.Count - 1] == null)
                {
                    articles.RemoveAt(articles.Count - 1);
                    check = true;
                }
            }
            catch (NullReferenceException)
            {
                return(RedirectToAction("Index", "Home"));
            }

            foreach (var a in articles)
            {
                OneArticle oneArticle = new OneArticle
                {
                    Article  = a,
                    Category = dataBaseCategory.Select(a.Category_Id)
                };

                fullArticles.Add(oneArticle);
            }

            ViewBag.index = ++id_page;
            ViewBag.end   = 0;
            if (check)
            {
                ViewBag.end = 1;
            }

            return(View(fullArticles));
        }
Exemplo n.º 7
0
        public ActionResult Index(int id = 1)
        {
            DataBaseArticles   dataBaseArticles = new DataBaseArticles();
            DataBaseCategories dataBaseCategory = new DataBaseCategories();

            var         articles    = dataBaseArticles.SelectTop10(id);
            SearchModel searchModel = new SearchModel();

            bool check = false;

            try
            {
                if (articles.Last() == null)
                {
                    articles.RemoveAt(articles.Count - 1);
                    check = true;
                }
            }
            catch (ArgumentNullException)
            {
                return(RedirectToAction("Index", "Home"));
            }

            foreach (var a in articles)
            {
                OneArticle oneArticle = new OneArticle
                {
                    Article  = a,
                    Category = dataBaseCategory.Select(a.Category_Id)
                };

                searchModel.OneArticles.Add(oneArticle);
            }

            searchModel.Categories = new SelectList(dataBaseCategory.Select(), "Category_Id", "Name");

            ViewBag.index = ++id;
            ViewBag.end   = 0;
            if (check)
            {
                ViewBag.end = 1;
            }

            return(View(searchModel));
        }
Exemplo n.º 8
0
        public ActionResult Edit(OneArticle oneArticle)
        {
            oneArticle.Article.DateTime = DateTime.Now;

            DataBaseArticles dataBaseArticles = new DataBaseArticles();

            dataBaseArticles.Update(oneArticle.Article);

            DataBaseTegs          dataBaseTeg           = new DataBaseTegs();
            DataBaseArticles_Tegs dataBaseArticles_Tegs = new DataBaseArticles_Tegs();

            string[] tegs = oneArticle.Teg.Split(new char[] { '#' }, StringSplitOptions.RemoveEmptyEntries);
            dataBaseArticles_Tegs.DeleteArticle(oneArticle.Article.Article_Id);

            foreach (string teg in tegs)
            {
                int id_teg = dataBaseTeg.Insert("#" + teg);
                dataBaseArticles_Tegs.Insert(oneArticle.Article.Article_Id, id_teg);
            }

            ModelState.AddModelError("", "Статья успешно изменена");

            return(Edit(oneArticle.Article.Article_Id));
        }
Exemplo n.º 9
0
 private void GridResult_PreviewMouseDown(object sender, MouseButtonEventArgs e)
 {
     if (ArticleButton.IsChecked == true)
     {
         var        currentArticle = (Model.Article)((Grid)sender).Tag;
         int?       id             = currentArticle.ArticleId;
         OneArticle one            = new OneArticle();
         OneArticle.articleId = (int)id;
         one.Title.Text       = currentArticle.Title;
         one.Text.Text        = currentArticle.Text;
         if (currentArticle.Image != null)
         {
             one.Source.Source = Pima.ViewModel.Converter.ConvertByteArrayToImage(currentArticle.Image);
         }
         else
         {
             one.Source.Visibility = Visibility.Collapsed;
         }
         CurrentPage.Navigate(one);
     }
     else if (NoteButton.IsChecked == true)
     {
         var     currentArticle = (Model.Notes)((Grid)sender).Tag;
         int?    id             = currentArticle.NotesId;
         OneNote one            = new OneNote();
         OneNote.articleId = (int)id;
         one.Name.Text     = currentArticle.Name;
         //one.Text.Text = currentArticle.Text;
         if (currentArticle.Note != null)
         {
             one.Source.Source = Pima.ViewModel.Converter.ConvertByteArrayToImage(currentArticle.Note);
         }
         else
         {
             one.Source.Visibility = Visibility.Collapsed;
         }
         CurrentPage.Navigate(one);
     }
     else if (SongButton.IsChecked == true)
     {
         var     currentSong = (Model.Songs)((Grid)sender).Tag;
         int?    id          = currentSong.SongsId;
         OneSong one         = new OneSong();
         OneSong.songID = (int)id;
         one.Name.Text  = currentSong.Name;
         //one.Text.Text = currentArticle.Text;
         if (currentSong.Image != null)
         {
             one.Source.Source = Pima.ViewModel.Converter.ConvertByteArrayToImage(currentSong.Image);
         }
         else
         {
             one.Source.Visibility = Visibility.Collapsed;
         }
         CurrentPage.Navigate(one);
     }
     else if (ChordButton.IsChecked == true)
     {
         var      currentChord = (Model.Chords)((Grid)sender).Tag;
         int?     id           = currentChord.ChordsId;
         OneChord one          = new OneChord();
         OneChord.ChordId = (int)id;
         one.Name.Text    = currentChord.Name;
         //one.Text.Text = currentArticle.Text;
         if (currentChord.Chord != null)
         {
             one.Source.Source = Pima.ViewModel.Converter.ConvertByteArrayToImage(currentChord.Chord);
         }
         else
         {
             one.Source.Visibility = Visibility.Collapsed;
         }
         CurrentPage.Navigate(one);
     }
 }
Exemplo n.º 10
0
        public MainWindowViewModel()
        {
            //NewsArticles.Add(new Article() { Title = "Uno" });
            //NewsArticles.Add(new Article() { SourceImg = "Dos" });
            //NewsArticles.Add(new Article() { Byline = "Tres" });

            #region Data binding first part

            foreach (Article u in Data.articles)
            {
                if (u.articleID > Data.articles.Count - 10)
                {
                    NewsArticles.Insert(0, u);
                }
            }

            foreach (Article u in Data.articles)
            {
                if (u.articleID == Data.articles.Count - 1)
                {
                    OneArticle.Insert(0, u);
                }
            }


            foreach (Article u in Data.articles)
            {
                if (u.articleID == Data.articles.Count - 2)
                {
                    OneArticle2.Insert(0, u);
                }
            }


            foreach (Article u in Data.articles)
            {
                if (u.articleID == Data.articles.Count - 3)
                {
                    OneArticle3.Insert(0, u);
                }
            }

            foreach (Article u in Data.articles)
            {
                if (u.articleID == Data.articles.Count - 4)
                {
                    OneArticle4.Insert(0, u);
                }
            }

            foreach (Article u in Data.articles)
            {
                if (u.articleID == Data.articles.Count - 5)
                {
                    OneArticle5.Insert(0, u);
                }
            }

            foreach (Article u in Data.articles)
            {
                if (u.articleID == Data.articles.Count - 6)
                {
                    OneArticle6.Insert(0, u);
                }
            }

            #endregion

            foreach (Article u in Data.articles)
            {
                if (SomeCategory.currentCategory == "News")
                {
                    if (u.articleID < Data.articles.Count & u.category == "News")
                    {
                        NewsArticles_Category.Insert(0, u);
                    }
                }
                else if (SomeCategory.currentCategory == "Politics")
                {
                    if (u.articleID < Data.articles.Count & u.category == "Politics")
                    {
                        //NewsArticles_Category.Clear();
                        NewsArticles_Category.Insert(0, u);
                    }
                }
                else if (SomeCategory.currentCategory == "Opinion")
                {
                    if (u.articleID < Data.articles.Count & u.category == "Opinion")
                    {
                        //NewsArticles_Category.Clear();
                        NewsArticles_Category.Insert(0, u);
                    }
                }
                else if (SomeCategory.currentCategory == "Sports")
                {
                    if (u.articleID < Data.articles.Count & u.category == "Sports")
                    {
                        //NewsArticles_Category.Clear();
                        NewsArticles_Category.Insert(0, u);
                    }
                }

                else if (SomeCategory.currentCategory == "Entertainment")
                {
                    if (u.articleID < Data.articles.Count & u.category == "Entertainment")
                    {
                        //NewsArticles_Category.Clear();
                        NewsArticles_Category.Insert(0, u);
                    }
                }
                else if (SomeCategory.currentCategory == "Social")
                {
                    if (u.articleID < Data.articles.Count & u.category == "Social")
                    {
                        //NewsArticles_Category.Clear();
                        NewsArticles_Category.Insert(0, u);
                    }
                }
            }
        }