public IActionResult Index()
        {
            SetViewBags();

            List <Test> tests = new List <Test>();

            List <string> links = ArticleBusiness.getLinks("https://www.wired.com/most-recent", "/html/body/div[3]/div/div[3]/div/div[2]/div/div[1]/div/div/ul/li", "https://www.wired.com");


            for (int i = 0; i < 5; i++)
            {
                HtmlNode[] header = ArticleBusiness.getNodesByXPath(links[i], "//h1");

                HtmlNode[] content = ArticleBusiness.getNodesByXPath(links[i], "//article//p");
                string     a       = "";
                for (int j = 0; j < content.Length; j++)
                {
                    a += "<p>" + content[j].InnerHtml + "</p>";
                }
                tests.Add(new Test {
                    title = header[0].InnerHtml.ToString(), content = a
                });
            }
            var model = new HomeViewModel {
                Tests = tests.ToArray()
            };

            return(View(model));
        }
Example #2
0
        public ArticleDeleteModel DeleteArticle(long pageID)
        {
            ArticleBusiness articleBusiness = new ArticleBusiness();

            ArticleDeleteModel articleDeleteModel = new ArticleDeleteModel();

            bool existPage = articleBusiness.ExistPageByArticleID(pageID);

            if (!existPage)
            {
                articleDeleteModel.Alerts.AlertList.Add("İçerik bulunamadı.");
                articleDeleteModel.Alerts.AlertType = Model.Base.Alerts.AlertTypes.Error;
            }
            else
            {
                try
                {
                    articleBusiness.DeleteArticle(pageID);

                    articleDeleteModel.Alerts.AlertList.Add("İçerik başarıyla silindi.");
                    articleDeleteModel.Alerts.AlertType = Model.Base.Alerts.AlertTypes.Success;
                }
                catch (Exception ex)
                {
                    articleDeleteModel.Alerts.AlertList.Add("İçerik silinemedi [ " + ex.Message + " ]");
                    articleDeleteModel.Alerts.AlertType = Model.Base.Alerts.AlertTypes.Error;
                }
            }

            articleDeleteModel.RedirectURL = "/Management/Article/Index";

            return(articleDeleteModel);
        }
Example #3
0
        private void Dispose(bool dispose)
        {
            if (dispose)
            {
                if (_articleBusiness != null)
                {
                    _articleBusiness = null;
                }

                if (_articlePhotoBusiness != null)
                {
                    _articlePhotoBusiness = null;
                }

                if (_nextEventBusiness != null)
                {
                    _nextEventBusiness = null;
                }

                if (_photoBusiness != null)
                {
                    _photoBusiness = null;
                }

                if (_playerPhotoBusiness != null)
                {
                    _playerPhotoBusiness = null;
                }

                if (_playerPositionBusiness != null)
                {
                    _playerPositionBusiness = null;
                }

                if (_playerBusiness != null)
                {
                    _playerBusiness = null;
                }

                if (_positionBusiness != null)
                {
                    _positionBusiness = null;
                }

                if (_userBusiness != null)
                {
                    _userBusiness = null;
                }
                if (_repositoryContext != null)
                {
                    _repositoryContext.Dispose();
                    _repositoryContext = null;
                }

                if (_instance != null)
                {
                    _instance = null;
                }
            }
        }
Example #4
0
        private void Bill_Load(object sender, EventArgs e)
        {
            ArticleBusiness ab = new ArticleBusiness();

            refresh();
            textBox1.Text = BillBusiness.currentBill.Total_Price.ToString();
            List <CaffeArticle> pica = ab.GetCaffeArticles();

            foreach (CaffeArticle c in pica.Where(x => x.Packaging == "Bezalkoholna pića").ToList())
            {
                comboBox1.Items.Add(c.ToString());
            }
            foreach (CaffeArticle c in pica.Where(x => x.Packaging == "Žestina").ToList())
            {
                comboBox2.Items.Add(c.ToString());
            }
            foreach (CaffeArticle c in pica.Where(x => x.Packaging == "Pivo").ToList())
            {
                comboBox3.Items.Add(c.ToString());
            }
            foreach (CaffeArticle c in pica.Where(x => x.Packaging == "Topli napici").ToList())
            {
                comboBox4.Items.Add(c.ToString());
            }
        }
        public HttpResponseMessage GetAllArticles()
        {
            List <Article> list = ArticleBusiness.GetArticle();

            articulo = new
            {
                articles = list,
                success  = true,
                total    = list.Count
            };
            return(Request.CreateResponse(HttpStatusCode.OK, articulo));
        }
Example #6
0
        public ArticleCreateModel ArticleCreate(ArticleCreateModel request)
        {
            ArticleCreateModel articleCreateModel = new ArticleCreateModel();

            LanguageBusiness languageBusiness = new LanguageBusiness();
            ArticleBusiness  articleBusiness  = new ArticleBusiness();

            IEnumerable <Language> languageList = languageBusiness.LanguageList();

            articleCreateModel.LanguageList = new SelectList(languageList, "ID", "Name", request.LanguageID);


            bool existLanguage = languageBusiness.ExistLanguage(request.LanguageID);

            if (!existLanguage)
            {
                articleCreateModel.Alerts.AlertList.Add("Dil bulunamadı!");
                articleCreateModel.Alerts.AlertType = Model.Base.Alerts.AlertTypes.Error;

                return(articleCreateModel);
            }
            else
            {
                bool existSeoName = articleBusiness.ExistSeoName(request.SeoName);

                if (existSeoName)
                {
                    articleCreateModel.Alerts.AlertList.Add("Seo adı daha önce kullanılmış!");
                    articleCreateModel.Alerts.AlertType = Model.Base.Alerts.AlertTypes.Error;

                    return(articleCreateModel);
                }
                else
                {
                    try
                    {
                        ArticleTranslation articleTranslation = articleBusiness.CreateArticleTranslation(request.LanguageID, request.Name, request.SeoName, request.SeoKeyword, request.SeoDescription, request.ShortText, request.LongText, request.Picture, request.ArticleType);

                        articleCreateModel.Alerts.AlertList.Add("İçerik başarıyla eklendi");
                        articleCreateModel.RedirectURL      = "/Management/Article/Index";
                        articleCreateModel.Alerts.AlertType = Model.Base.Alerts.AlertTypes.Success;
                    }
                    catch (Exception ex)
                    {
                        articleCreateModel.Alerts.AlertList.Add("İçerik kaydedilemedi [ " + ex.Message + " ]");
                        articleCreateModel.Alerts.AlertType = Model.Base.Alerts.AlertTypes.Error;
                    }
                }
            }

            return(articleCreateModel);
        }
 public HttpResponseMessage DeleteArticles(int id)
 {
     if ((!id.Equals(0)))
     {
         articulo = new
         {
             success = true,
             article = ArticleBusiness.DeleteArticle(id)
         };
         return(Request.CreateResponse(HttpStatusCode.OK, articulo));
     }
     return(Request.CreateResponse(HttpStatusCode.BadRequest, MsgError("Invalid Id Article", 404)));
 }
 public HttpResponseMessage EditArticles(int id, [FromBody()] Article article)
 {
     if ((article.Id.Equals(id)))
     {
         articulo = new
         {
             success = true,
             article = ArticleBusiness.EditArticle(ref article)
         };
         return(Request.CreateResponse(HttpStatusCode.Created, articulo));
     }
     return(Request.CreateResponse(HttpStatusCode.BadRequest, MsgError("Invalid Id Article", 404)));
 }
 public HttpResponseMessage AddArticles([FromBody()] Article article)
 {
     if ((ModelState.IsValid))
     {
         articulo = new
         {
             success = true,
             article = ArticleBusiness.AddArticle(article)
         };
         return(Request.CreateResponse(HttpStatusCode.Created, articulo));
     }
     return(Request.CreateResponse(HttpStatusCode.BadRequest, MsgError("Record not Found", 404)));
 }
Example #10
0
        public ArticleIndexModel LoadIndex(int page)
        {
            ArticleIndexModel articleIndexModel = new ArticleIndexModel();

            ArticleBusiness articleBusiness = new ArticleBusiness();

            List <Article> articleList = articleBusiness.ArticleList(page);

            articleIndexModel.ArticleList = (from z in articleList
                                             select new ArticleItemModel
            {
                ID = z.ID,
                Name = z.ArticleTranslation.FirstOrDefault().Name
            }).ToList();

            return(articleIndexModel);
        }
        public HttpResponseMessage GetArticleId(int id)
        {
            Article article = ArticleBusiness.GetArticleById(ref id);

            if (article == null)
            {
                respuesta = Request.CreateResponse(HttpStatusCode.NotFound, MsgError("Record not Found", 404));
                return(respuesta);
            }
            articulo = new
            {
                article = article,
                success = true,
                total   = 1
            };
            return(Request.CreateResponse(HttpStatusCode.OK, articulo));
        }
Example #12
0
        public void refresh()
        {
            comboBox1.Text = "Bezalkoholna pica";
            comboBox2.Text = "Zestina";
            comboBox3.Text = "Pivo";
            comboBox4.Text = "Topli napici";
            listBox1.Items.Clear();
            textBox1.Text = BillBusiness.currentBill.Total_Price.ToString();
            ArticleBusiness  ab  = new ArticleBusiness();
            BillItemBusiness bib = new BillItemBusiness();

            foreach (CaffeBillItem b in bib.GetCaffeBillItems())
            {
                if (b.Bill_ID == BillBusiness.currentBill.Bill_ID)
                {
                    CaffeArticle temp = ab.GetCaffeArticles().Where(x => x.Article_ID == b.Article_ID).ToList()[0];
                    listBox1.Items.Add(temp.ToString() + " x" + b.Quantity);
                }
            }
        }
Example #13
0
 public ArticleController()
 {
     this.articleBusiness = new ArticleBusiness();
 }
Example #14
0
        private void button1_Click(object sender, EventArgs e)
        {
            BillBusiness     billb = new BillBusiness();
            BillItemBusiness bb    = new BillItemBusiness();
            ArticleBusiness  ab    = new ArticleBusiness();

            if (comboBox1.Text != "Bezalkoholna pica")
            {
                string       tempname = comboBox1.Text.Split('-')[0];
                CaffeArticle ca       = ab.GetCaffeArticles().Where(x => x.Name == tempname).ToList()[0];
                BillBusiness.currentBill.Total_Price += ca.Price;
                billb.UpdateCaffeBill(BillBusiness.currentBill);
                try
                {
                    CaffeBillItem cb = new CaffeBillItem(ca.Article_ID, BillBusiness.currentBill.Bill_ID, 1);
                    bb.InsertBillItem(cb);
                }
                catch
                {
                    CaffeBillItem zeka = bb.GetCaffeBillItems().Where(x => x.Article_ID == ca.Article_ID && x.Bill_ID == BillBusiness.currentBill.Bill_ID).ToList()[0];
                    zeka.Quantity++;
                    bb.UpdateBillItem(zeka);
                }
                refresh();
            }
            if (comboBox2.Text != "Zestina")
            {
                string       tempname = comboBox2.Text.Split('-')[0];
                CaffeArticle ca       = ab.GetCaffeArticles().Where(x => x.Name == tempname).ToList()[0];
                BillBusiness.currentBill.Total_Price += ca.Price;
                billb.UpdateCaffeBill(BillBusiness.currentBill);
                try
                {
                    CaffeBillItem cb = new CaffeBillItem(ca.Article_ID, BillBusiness.currentBill.Bill_ID, 1);
                    bb.InsertBillItem(cb);
                }
                catch
                {
                    CaffeBillItem zeka = bb.GetCaffeBillItems().Where(x => x.Article_ID == ca.Article_ID && x.Bill_ID == BillBusiness.currentBill.Bill_ID).ToList()[0];
                    zeka.Quantity++;
                    bb.UpdateBillItem(zeka);
                }
                refresh();
            }
            if (comboBox3.Text != "Pivo")
            {
                string       tempname = comboBox3.Text.Split('-')[0];
                CaffeArticle ca       = ab.GetCaffeArticles().Where(x => x.Name == tempname).ToList()[0];
                BillBusiness.currentBill.Total_Price += ca.Price;
                billb.UpdateCaffeBill(BillBusiness.currentBill);
                try
                {
                    CaffeBillItem cb = new CaffeBillItem(ca.Article_ID, BillBusiness.currentBill.Bill_ID, 1);
                    bb.InsertBillItem(cb);
                }
                catch
                {
                    CaffeBillItem zeka = bb.GetCaffeBillItems().Where(x => x.Article_ID == ca.Article_ID && x.Bill_ID == BillBusiness.currentBill.Bill_ID).ToList()[0];
                    zeka.Quantity++;
                    bb.UpdateBillItem(zeka);
                }
                refresh();
            }
            if (comboBox4.Text != "Topli napici")
            {
                string       tempname = comboBox4.Text.Split('-')[0];
                CaffeArticle ca       = ab.GetCaffeArticles().Where(x => x.Name == tempname).ToList()[0];
                BillBusiness.currentBill.Total_Price += ca.Price;
                billb.UpdateCaffeBill(BillBusiness.currentBill);
                try
                {
                    CaffeBillItem cb = new CaffeBillItem(ca.Article_ID, BillBusiness.currentBill.Bill_ID, 1);
                    bb.InsertBillItem(cb);
                }
                catch
                {
                    CaffeBillItem zeka = bb.GetCaffeBillItems().Where(x => x.Article_ID == ca.Article_ID && x.Bill_ID == BillBusiness.currentBill.Bill_ID).ToList()[0];
                    zeka.Quantity++;
                    bb.UpdateBillItem(zeka);
                }
                refresh();
            }
        }