Example #1
0
        public ActionResult Index(int id)
        {
            ViewModel obj = new ViewModel();
            var       ctx = new CosmicVerseEntities1();

            //Article
            List <Article> querylist = new List <Article>();

            querylist = (from m in ctx.Articles
                         where m.ID == id
                         select m).ToList();
            foreach (var item in querylist)
            {
                obj.ArticleDateTime = item.DateTime.ToString();
                obj.ArticleTitle    = item.Title;
                obj.Body            = item.Body;
                obj.ShortDesc       = item.ShortDesc;
                obj.Author          = item.Author;
                obj.ArticleID       = item.ID;
            }


            IEnumerable <Treeview.Comment> querylistC;

            querylistC = (from m in ctx.Comments
                          where m.ArticleID == id && m.Flag == true
                          select m);

            obj.allComments = querylistC;

            return(View(obj));
        }
        public ActionResult SaveNode(string childid, string parentid)
        {
            //*****REVISION******Do not allow reportsto = itself
            if (childid != null && parentid != null && parentid != childid)
            {
                string source      = childid;
                string destination = parentid;
                using (var ctx = new CosmicVerseEntities1())
                {
                    var personals = ctx.Personals.Where(m => m.Name == source).First();

                    var personalsParent = ctx.Personals.Where(m => m.Name == destination).First();

                    //***check
                    //*****REVISION******Do not allow make circle in data base such as P1 is parent for P2 and also P2 is parent for P1 ==> Prevent these mistake by checking it
                    //

                    if (personalsParent.ReportsTo != personals.ID)
                    {
                        personals.ReportsTo = Convert.ToInt16(personalsParent.ID);


                        ctx.SaveChanges();
                    }
                    //***check
                }
            }
            return(RedirectToAction("Index"));
        }
Example #3
0
        public ActionResult CreateContent(Treeview.Models.Content content)
        {
            using (var ctx = new CosmicVerseEntities1())
            {
                Content cont = new Content();
                cont.Title = content.ContentTitle;
                cont.Body  = content.ContentBody;

                contentRepository.InsertContent(cont);
                contentRepository.Save();
            }
            return(RedirectToAction("Index"));
        }
Example #4
0
        public ActionResult Links()
        {
            Content cont = new Content();

            Treeview.Models.Content contM = new Treeview.Models.Content();

            using (var ctx = new CosmicVerseEntities1())
            {
                cont = contentRepository.GetContentByID(4);
                contM.ContentTitle = cont.Title;
                contM.ContentBody  = cont.Body;
            }
            return(View(contM));
        }
Example #5
0
        public ActionResult Edit(Content content)
        {
            // string strmy=Request.QueryString["Body"];
            using (var ctx = new CosmicVerseEntities1())
            {
                Content cont = new Content();
                cont.ID    = content.ID;
                cont.Title = content.Title;
                cont.Body  = content.Body;



                contentRepository.UpdateContent(cont);
                contentRepository.Save();
            }
            return(RedirectToAction("Index"));
        }
Example #6
0
        public ActionResult Edit(ViewModel article)
        {
            // string strmy=Request.QueryString["Body"];
            using (var ctx = new CosmicVerseEntities1())
            {
                Article art = new Article();
                art.ID        = article.ArticleID;
                art.Title     = article.ArticleTitle;
                art.Body      = article.Body;
                art.ShortDesc = article.ShortDesc;
                art.DateTime  = DateTime.Now.DayOfWeek.ToString() + " " + DateTime.Now.Month.ToString() + " " + DateTime.Now.Year.ToString() + " " + DateTime.Now.Hour.ToString() + ":" + DateTime.Now.Minute.ToString();
                art.Author    = "Mahsa Hassankashi";

                articleRepository.UpdateArticle(art);
                articleRepository.Save();
            }
            return(RedirectToAction("Index"));
        }
Example #7
0
        public ActionResult Comment(ViewModel vcomment)
        {
            // string strmy=Request.QueryString["Body"];
            using (var ctx = new CosmicVerseEntities1())
            {
                Comment com = new Comment();

                com.ArticleID = vcomment.ArticleID;
                com.Title     = vcomment.ArticleTitle;
                com.BodyMsg   = vcomment.BodyMsg;
                com.Name      = vcomment.Name;
                com.Email     = vcomment.Email;
                com.DateTime  = DateTime.Now.DayOfWeek.ToString() + " " + DateTime.Now.Month.ToString() + " " + DateTime.Now.Year.ToString() + " " + DateTime.Now.Hour.ToString() + ":" + DateTime.Now.Minute.ToString();
                com.Flag      = false;
                //************START
                try
                {
                    MailMessage objeto_mail = new MailMessage();
                    SmtpClient  client      = new SmtpClient();
                    client.Port                  = 25;
                    client.Host                  = "smtp.internal.cosmicverse.info";
                    client.Timeout               = 10000;
                    client.DeliveryMethod        = SmtpDeliveryMethod.Network;
                    client.UseDefaultCredentials = false;
                    client.Credentials           = new System.Net.NetworkCredential("*****@*****.**", "75337533");
                    objeto_mail.From             = new MailAddress("*****@*****.**");
                    objeto_mail.To.Add(new MailAddress(vcomment.Email));
                    objeto_mail.Bcc.Add(new MailAddress("*****@*****.**"));
                    objeto_mail.Subject = "cosmic verse";
                    objeto_mail.Body    = "Thank you dear for your comment. Your comment is in queue process";
                    client.Send(objeto_mail);
                }
                catch (Exception ex)
                {
                }


                //***************END
                commentRepository.InsertComment(com);
                commentRepository.Save();
            }
            //Notification : your message is in confirm process
            return(RedirectToAction("Index"));
        }
Example #8
0
        //**************
        //***********

        public ActionResult EditView(int id)
        {
            Content obj = new Content();
            var     ctx = new CosmicVerseEntities1();

            //Article
            List <Content> querylist = new List <Content>();

            querylist = (from m in ctx.Contents
                         where m.ID == id
                         select m).ToList();
            foreach (var item in querylist)
            {
                obj.ID    = item.ID;
                obj.Title = item.Title;
                obj.Body  = item.Body;
            }

            return(View(obj));
        }
Example #9
0
        public ActionResult EditView(int id)
        {
            ViewModel obj = new ViewModel();
            var       ctx = new CosmicVerseEntities1();

            //Article
            List <Article> querylist = new List <Article>();

            querylist = (from m in ctx.Articles
                         where m.ID == id
                         select m).ToList();
            foreach (var item in querylist)
            {
                obj.ArticleDateTime = item.DateTime.ToString();
                obj.ArticleTitle    = item.Title;
                obj.Body            = item.Body;
                obj.ShortDesc       = item.ShortDesc;
                obj.Author          = item.Author;
                obj.ArticleID       = item.ID;
            }

            return(View(obj));
        }
Example #10
0
        public ActionResult CommentList()
        {
            //string strID=TempData["articleID"].ToString();

            IEnumerable <Comment> obj = commentRepository.GetCommentByArticleID(1);
            var ctx = new CosmicVerseEntities1();


            ////Comment
            //List<Comment> querylistC = new List<Comment>();
            //querylistC = (from m in ctx.Comments
            //              where m.ArticleID == Convert.ToInt16(strID) && m.Flag == true
            //              select m).ToList();
            //foreach (var item in querylistC)
            //{
            //    obj.Name = item.Name;
            //    obj.Email = item.Email;
            //    obj.BodyMsg = item.BodyMsg;
            //    obj.commentDateTime = item.DateTime;


            //}
            return(View(obj));
        }
Example #11
0
        public ActionResult LinkHit(string link)
        {
            //this line is to check the clien ip address from the server itself
            string IP = "";

            string strHostName = "";

            strHostName = System.Net.Dns.GetHostName();

            IPHostEntry ipEntry = System.Net.Dns.GetHostEntry(strHostName);

            IPAddress[] addr = ipEntry.AddressList;

            IP = addr[2].ToString();

            //Initializing a new xml document object to begin reading the xml file returned
            XmlDocument doc = new XmlDocument();

            doc.Load("http://www.freegeoip.net/xml");
            XmlNodeList nodeLst_IP          = doc.GetElementsByTagName("Ip");
            XmlNodeList nodeLst_CountryCode = doc.GetElementsByTagName("CountryCode");
            XmlNodeList nodeLst_CountryName = doc.GetElementsByTagName("CountryName");
            XmlNodeList nodeLst_RegionCode  = doc.GetElementsByTagName("RegionCode");
            XmlNodeList nodeLst_RegionName  = doc.GetElementsByTagName("RegionName");
            XmlNodeList nodeLst_City        = doc.GetElementsByTagName("City");
            XmlNodeList nodeLst_ZipCode     = doc.GetElementsByTagName("ZipCode");
            XmlNodeList nodeLst_Latitude    = doc.GetElementsByTagName("Latitude");
            XmlNodeList nodeLst_Longitude   = doc.GetElementsByTagName("Longitude");
            XmlNodeList nodeLst_MetroCode   = doc.GetElementsByTagName("MetroCode");
            XmlNodeList nodeLst_AreaCode    = doc.GetElementsByTagName("AreaCode");

            //IP = "" + nodeLst_IP[0].InnerText + "<br>" + nodeLst_CountryCode[0].InnerText + "<br>" +
            //   nodeLst_CountryName[0].InnerText;

            //Response.Write(IP);
            //this is my header that I love

            if (link != null)
            {
                string source = link;
                //string destination = parentid;
                using (var ctx = new CosmicVerseEntities1())
                {
                    LinkHit lnkhit = new LinkHit();

                    lnkhit.Link        = link;
                    lnkhit.Date        = DateTime.Now.Date.Date.ToString();
                    lnkhit.Time        = DateTime.Now.TimeOfDay.ToString();
                    lnkhit.countrycode = nodeLst_CountryCode[0].InnerText;
                    lnkhit.countryname = nodeLst_CountryName[0].InnerText;
                    lnkhit.city        = nodeLst_City[0].InnerText;
                    lnkhit.IP          = nodeLst_IP[0].InnerText;
                    lnkhit.regioncode  = nodeLst_RegionCode[0].InnerText;
                    lnkhit.regionname  = nodeLst_RegionName[0].InnerText;
                    lnkhit.areacode    = nodeLst_AreaCode[0].InnerText;
                    lnkhit.longitude   = nodeLst_Longitude[0].InnerText;
                    lnkhit.latitude    = nodeLst_Latitude[0].InnerText;
                    lnkhit.zipcode     = nodeLst_ZipCode[0].InnerText;


                    ctx.LinkHits.Add(lnkhit);
                    ctx.SaveChanges();
                }
            }
            return(RedirectToAction(link));
        }
        public string Treeview(int itemID, string mystr, int j, int flag)
        {
            List <Personal> querylist = new List <Personal>();
            var             ctx       = new CosmicVerseEntities1();

            if (flag == 0)
            {
                querylist = (from m in ctx.Personals
                             where m.ReportsTo == null
                             select m).ToList();
                mainNode = querylist.Count;

                mystr += "[";
            }
            if (flag == 1)
            {
                querylist = (from m in ctx.Personals
                             where m.ReportsTo == itemID
                             select m).ToList();
                mainNode = querylist.Count;
                mystr   += ",items:[";
            }

            //Below line shows an example of how to make parent node with his child
            //[{ id: "1", text: "P1", items: [{ id: "5", text: "P2" }] }]


            int i = 1;

            foreach (var item in querylist)
            {
                myflag = 0;
                mystr += "{id:\"" + item.ID + "\",text:\"" + item.Name + "\"";
                List <Personal> querylistParent = new List <Personal>();
                //Check this parent has child or not , if yes how many?
                querylistParent = (from m in ctx.Personals
                                   where m.ReportsTo == item.ID
                                   select m).ToList();
                childquantity = querylistParent.Count;
                //If Parent Has Child again call Treeview with new parameter
                if (childquantity > 0)
                {
                    mystr = Treeview(item.ID, mystr, i, 1);
                }
                //No Child and No Last Node
                else if (childquantity == 0 && i < querylist.Count)
                {
                    mystr += "},";
                }
                //No Child and Last Node
                else if (childquantity == 0 && i == querylist.Count)
                {
                    int fcheck2   = 0;
                    int fcheck3   = 0;
                    int counter   = 0;
                    int flagbreak = 0;

                    int             currentparent;
                    List <Personal> parentquery;
                    List <Personal> childlistquery;
                    TempData["counter"] = 0;
                    currentparent       = Convert.ToInt16(item.ReportsTo);
                    int coun;
                    while (currentparent != 0)
                    {
                        //count parent of parent

                        fcheck2     = 0;
                        fcheck3     = 0;
                        parentquery = new List <Personal>();
                        parentquery = (from m in ctx.Personals
                                       where m.ID == currentparent
                                       select m).ToList();
                        var rep2 = (from h in parentquery select new { h.ReportsTo }).First();

                        //put {[ up to end

                        //list of child
                        childlistquery = new List <Personal>();
                        childlistquery = (from m in ctx.Personals
                                          where m.ReportsTo == currentparent
                                          select m).ToList();


                        foreach (var item22 in childlistquery)
                        {
                            if (mystr.Contains(item22.ID.ToString()))
                            {
                                if (item22.ReportsTo == currentparent)
                                {
                                    fcheck3 += 1;
                                    if (fcheck3 == 1)
                                    {
                                        counter += 1;
                                    }
                                }
                            }
                            else
                            {
                                myflag = 1;
                                if (item22.ReportsTo == currentparent)
                                {
                                    fcheck2 += 1;
                                    if (fcheck2 == 1)
                                    {
                                        counter  -= 1;
                                        flagbreak = 1;
                                    }
                                }
                            }
                        }

                        var result55 = (from h in parentquery select new { h.ID }).First();
                        coun             = Convert.ToInt16(result55.ID);
                        TempData["coun"] = Convert.ToInt16(coun);
                        currentparent    = Convert.ToInt16(rep2.ReportsTo);
                        if (flagbreak == 1)
                        {
                            break;
                        }
                    }

                    for (int i2 = 0; i2 < counter; i2++)
                    {
                        mystr += "}]";
                    }

                    List <Personal> lastchild = new List <Personal>();
                    lastchild = (from m in ctx.Personals
                                 where m.ReportsTo == item.ReportsTo
                                 select m).ToList();

                    List <Personal> lastparent = new List <Personal>();
                    lastparent = (from m in ctx.Personals
                                  where m.ReportsTo == null
                                  select m).ToList();

                    if (lastchild.Count > 0)
                    {
                        var result_lastchild  = (from h in lastchild select new { h.ID }).Last();
                        var result_lastparent = (from h in lastparent select new { h.ID }).Last();
                        int mycount           = Convert.ToInt16(TempData["coun"]);
                        if (item.ID == result_lastchild.ID && mycount == result_lastparent.ID && myflag == 0)
                        {
                            mystr += "}]";
                        }
                        else if (item.ID == result_lastchild.ID && mycount == result_lastparent.ID && myflag == 1)
                        {
                            mystr += "},";
                        }
                        else if (item.ID == result_lastchild.ID && mycount != result_lastparent.ID)
                        {
                            mystr += "},";
                        }
                    }
                    //  finish }]
                    else if (lastchild.Count == 0 && item.ReportsTo == null)
                    {
                        mystr += "}]";
                    }
                }
                i++;
            }


            return(mystr);
        }