public ActionResult Secure(string id)
 {
     if (id != null)
     {
         using (damianlukasik3612_crystalsiegeEntities contents = new damianlukasik3612_crystalsiegeEntities())
         {
             id = CoderUTF8.Encode(id);
             Secure idx = contents.Secures.Where(u => u.link == id).FirstOrDefault();
             Person per = contents.People.Where(u => u.access == 1).FirstOrDefault();
             if (idx != null)
             {
                 ViewBag.Title   = Resources.HomeTexts.YourLoginDate;
                 ViewBag.Message = "<div><dl class='dl-horizontal'></dl><dt>" + Resources.HomeTexts.Login + ":</dt><dd>" + per.username + "</dd><dt>" + Resources.HomeTexts.password + ":</dt><dd>" + per.password + "</dd></div>";
             }
             else
             {
                 ViewBag.Title   = Resources.HomeTexts.ThePasswordRecoverySitelinkDoesNotExist;
                 ViewBag.Message = "<div class='container body-content'><br><img class='media-object img-rounded' src='../Resources/Image/haha_zecora.png' width='210px' height='210px'><br>";
             }
             var t = contents.Secures.Where(u => u.link == id).First();
             contents.Secures.Remove(t);
             contents.SaveChanges();
         }
         return(View());
     }
     else
     {
         return(View("Home/Index"));
     }
 }
        // GET: Contents
        public ActionResult Index(int id)
        {
            var myCookie = GetCookie();

            using (damianlukasik3612_crystalsiegeEntities contents = new damianlukasik3612_crystalsiegeEntities())
            {
                string tab = "";
                if (myCookie != null)
                {
                    switch (myCookie)
                    {
                    case "pl":
                        tab = contents.Subsections
                              .Where(u => u.Id == id)
                              .FirstOrDefault().content;
                        break;

                    case "en":
                        tab = contents.Subsections
                              .Where(u => u.Id == id)
                              .FirstOrDefault().content_ang;
                        break;
                    }
                }
                else
                {
                    tab = contents.Subsections
                          .Where(u => u.Id == id)
                          .FirstOrDefault().content;
                }
                String str = Server.HtmlDecode(tab);
                ViewBag.Message = CoderUTF8.Decode(str);
            }
            return(View());
        }
Пример #3
0
        // POST api/graph
        public string Post([FromBody] IDictionary <string, string> value)
        {
            Boolean log = Authentication(value["username"], value["password"]);

            if (log)
            {
                string str;
                //
                using (damianlukasik3612_crystalsiegeEntities contex = new damianlukasik3612_crystalsiegeEntities())
                {
                    int i = 0;
                    if (contex.Secures.FirstOrDefault() != null)
                    {
                        List <Secure> list_sec = contex.Secures.ToList();
                        i = list_sec.Last().Id;
                        foreach (Secure sc in list_sec)
                        {
                            contex.Secures.Remove(sc);
                        }
                        contex.SaveChanges();
                    }
                    Secure sec = new Secure();
                    sec.Id = i + 1;
                    Random rand = new Random();
                    str      = CoderUTF8.Encode(rand.Next(0, 999).ToString() + value["password"] + rand.Next(0, 999).ToString());
                    sec.link = str;
                    contex.Secures.Add(sec);
                    contex.SaveChanges();
                }
                //
                return(str);
            }
            return("fail");
        }
        public ActionResult News(int news)
        {
            var myCookie = GetCookie();

            if (news != null)
            {
                using (damianlukasik3612_crystalsiegeEntities contents = new damianlukasik3612_crystalsiegeEntities())
                {
                    News          news_ = contents.News.Where(u => u.Id == news).FirstOrDefault();
                    List <String> str   = new List <String>();
                    switch (myCookie)
                    {
                    case "pl":
                        str.Add(CoderUTF8.Decode(news_.title));       //[0]
                        str.Add(CoderUTF8.Decode(news_.description)); //[1]
                        break;

                    case "en":
                        str.Add(CoderUTF8.Decode(news_.title_eng));       //[0]
                        str.Add(CoderUTF8.Decode(news_.description_eng)); //[1]
                        break;
                    }
                    str.Add(news_.author);                                                                                           //[2]
                    str.Add(DecodeDate(news_.date.Value.ToString("G",
                                                                 System.Globalization.CultureInfo.CreateSpecificCulture("en-US")))); //[3]
                    str.Add(Server.HtmlDecode(news_.image));                                                                         //[4]
                    List <News_Tags> news_tags = news_.News_Tags.ToList();
                    String           tagi      = "";
                    switch (myCookie)
                    {
                    case "pl":
                        foreach (News_Tags nt in news_tags)
                        {
                            tagi += " <span class='label label-success' style='background-color: " + nt.Tag.color + "'>" + nt.Tag.tags_pl + "</span> ";
                        }
                        break;

                    case "en":
                        foreach (News_Tags nt in news_tags)
                        {
                            tagi += " <span class='label label-success' style='background-color: " + nt.Tag.color + "'>" + nt.Tag.tags + "</span> ";
                        }
                        break;
                    }
                    str.Add(tagi);//[5]
                    ViewBag.Message = str;
                }
                return(View());
            }
            return(View("~/Views/Home/Index.cshtml"));
        }
Пример #5
0
        // GET: /Contents/Index
        public ActionResult Index(int id)
        {
            //var myCookie = GetCookie();

            using (CrystalSiegeEntities contents = new CrystalSiegeEntities())
            {
                string      tab = "";
                Subsections sec = contents.Subsections.Where(u => u.Id == id).FirstOrDefault();
                //save visit to db
                VisitModel.SaveVisitToDB("Content - |" + sec.SectionsId + "|" + sec.Id + "|" + CoderUTF8.Decode(sec.Sections.title) + "|" + CoderUTF8.Decode(sec.title));
                ViewBag.Message = CoderUTF8.Decode(Server.HtmlDecode(sec.content));
            }
            return(View());
        }
        public List <String[]> ReadCarouselInfo()
        {
            var myCookie = GetCookie();

            List <String[]> dane = new List <String[]>();

            using (damianlukasik3612_crystalsiegeEntities contents = new damianlukasik3612_crystalsiegeEntities())
            {
                List <CarouselInfo> tab = contents.CarouselInfoes.ToList();

                foreach (CarouselInfo wart in tab)
                {
                    if (wart.Link == "")
                    {
                        wart.Link = "http://crystalsiege.eu/";
                    }
                    else
                    {
                        wart.Link = CoderUTF8.Decode(wart.Link);
                    }
                    switch (myCookie)
                    {
                    case "en":
                        String[] str2 =
                        {
                            CoderUTF8.Decode(wart.Title_ang),
                            CoderUTF8.Decode(wart.Description_ang),
                            wart.image,
                            wart.Link
                        };
                        dane.Add(str2);
                        break;

                    case "pl":
                        String[] str1 =
                        {
                            CoderUTF8.Decode(wart.Title),
                            CoderUTF8.Decode(wart.Description),
                            wart.image,
                            wart.Link
                        };
                        dane.Add(str1);
                        break;
                    }
                }
                return(dane);
            }
            return(dane);
        }
Пример #7
0
        public List <Sections> getAllSections()
        {
            List <Sections> result = new List <Sections>();

            using (CrystalSiegeEntities content = new CrystalSiegeEntities())
            {
                result = content.Sections.OrderBy(s => s.Id).ToList();
                if (result.Count == 0)
                {
                    return(null);
                }
                foreach (Sections item in result)
                {
                    item.title = CoderUTF8.Decode(item.title);
                }
            }
            return(result);
        }
Пример #8
0
        /*
         * public int ID { get; set; }
         * public string Title { get; set; }
         * public string Content { get; set; }
         * public string Author { get; set; }
         * [DisplayFormat(DataFormatString = "{0:yyyy-MM-dd}", ApplyFormatInEditMode = true)]
         * public DateTime DatePublish { get; set; }
         * public Boolean IsPublish { get; set; }
         * public string ImageSrc { get; set; }
         * public int PaperclipType { get; set; }*/

        /* przekazuje listę swoich obiektów */
        public List <News> getAllNews(int pub)
        {
            List <News> result = new List <News>();

            using (CrystalSiegeEntities content = new CrystalSiegeEntities())
            {
                result = content.News.Where(q => q.publish >= pub).OrderByDescending(s => s.date).ToList();
                if (result.Count == 0)
                {
                    return(null);
                }
                foreach (News item in result)
                {
                    item.title       = CoderUTF8.Decode(item.title);
                    item.description = CoderUTF8.Decode(item.description);
                }
            }
            return(result);
        }
Пример #9
0
        public List <CarouselInfo> getAllSlides()
        {
            List <CarouselInfo> result = new List <CarouselInfo>();

            using (CrystalSiegeEntities content = new CrystalSiegeEntities())
            {
                result = content.CarouselInfo.OrderBy(s => s.Id).ToList();
                if (result.Count == 0)
                {
                    return(null);
                }
                foreach (CarouselInfo item in result)
                {
                    item.Title       = CoderUTF8.Decode(item.Title);
                    item.Description = CoderUTF8.Decode(item.Description);
                    item.Link        = CoderUTF8.Decode(item.Link);
                }
            }
            return(result);
        }
Пример #10
0
        public List <List <Subsections> > getAllSubsections()
        {
            List <Sections>            result1 = new List <Sections>();
            List <List <Subsections> > result2 = new List <List <Subsections> >();

            using (CrystalSiegeEntities content = new CrystalSiegeEntities())
            {
                result1 = content.Sections.OrderBy(s => s.Id).ToList();
                if (result1.Count == 0)
                {
                    return(null);
                }
                foreach (Sections item in result1)
                {
                    List <Subsections> tmp = content.Sections.Where(s => s.Id == item.Id).SingleOrDefault().Subsections.ToList();
                    foreach (Subsections item2 in tmp)
                    {
                        item2.title = CoderUTF8.Decode(item2.title);
                    }
                    result2.Add(tmp);
                }
            }
            return(result2);
        }
        public ActionResult SearchResult(string search)
        {
            string[] searchs = search.Split(' ');//słowa kluczowe

            List <List <string[]> > result      = new List <List <string[]> >();
            List <string[]>         wyniki_news = new List <string[]>();
            List <string[]>         wyniki_cont = new List <string[]>();

            using (damianlukasik3612_crystalsiegeEntities contents = new damianlukasik3612_crystalsiegeEntities())
            {//sprawdzać njusy
                List <News> news_list = contents.News.ToList();
                Boolean     log, log_title, log_desc, log_author;
                foreach (News news in news_list)
                {
                    log        = false;
                    log_title  = false;
                    log_desc   = false;
                    log_author = false;
                    string str_title_desc = "";

                    List <News_Tags> news_tags = news.News_Tags.ToList();
                    foreach (News_Tags tg in news_tags)
                    {//po wszystkich tagach
                        string title_ = "";
                        string tags_  = "";
                        switch (Resources.HomeTexts.lang_set)
                        {
                        case "pl":
                            if (Search(tg.Tag.tags_pl, searchs))
                            {
                                title_ = news.title;
                                tags_  = tg.Tag.tags_pl.ToString();
                                log    = true;
                            }
                            break;

                        case "en":
                            if (Search(tg.Tag.tags, searchs))
                            {
                                title_ = news.title_eng;
                                tags_  = tg.Tag.tags.ToString();
                                log    = true;
                            }
                            break;
                        }
                        if (log)
                        {
                            string[] tab_s =
                            {
                                news.Id.ToString(),                                                                                                             //[0]
                                CoderUTF8.Decode(title_),                                                                                                       //[1]
                                "tag " + tg.Tag.color + " " + tags_ + "",                                                                                       //[2]
                                new ContentsController().DecodeDate(news.date.Value.ToString("G",
                                                                                             System.Globalization.CultureInfo.CreateSpecificCulture("en-US"))), //[3]
                                news.author                                                                                                                     //[4]
                            };
                            wyniki_news.Add(tab_s);
                            break;
                        }
                    }
                    if (log)
                    {
                        continue;
                    }
                    if (Search(CoderUTF8.Decode(news.title), searchs))
                    {//po tytule
                        log_title      = true;
                        str_title_desc = Resources.HomeTexts.InTitle;
                    }
                    else if (Search(CoderUTF8.Decode(news.description), searchs))
                    {//po opisie
                        log_desc       = true;
                        str_title_desc = Resources.HomeTexts.InContentNews;
                    }
                    else if (Search(CoderUTF8.Decode(news.author), searchs))
                    {//po nazwie autora
                        log_author     = true;
                        str_title_desc = Resources.HomeTexts.InNameAuthor;
                    }
                    ;
                    if (log_desc || log_title || log_author)
                    {
                        string title_ = "";
                        switch (Resources.HomeTexts.lang_set)
                        {
                        case "pl":
                            title_ = news.title;
                            break;

                        case "en":
                            title_ = news.title_eng;
                            break;
                        }
                        log = true;
                        string[] tab_s =
                        {
                            news.Id.ToString(),                                                                                                             //[0]
                            CoderUTF8.Decode(title_),                                                                                                       //[1]
                            str_title_desc,                                                                                                                 //Tytuł - \" " + CoderUTF8.Decode(wart.title) + "\"",//[2]
                            new ContentsController().DecodeDate(news.date.Value.ToString("G",
                                                                                         System.Globalization.CultureInfo.CreateSpecificCulture("en-US"))), //[3]
                            news.author                                                                                                                     //[4]
                        };
                        wyniki_news.Add(tab_s);
                        continue;
                    }
                }
                //sprawdzać content
                List <Subsection> subs = contents.Subsections.ToList();
                foreach (Subsection sec in subs)
                {
                    switch (Resources.HomeTexts.lang_set)
                    {
                    case "pl":
                        if (Search(CoderUTF8.Decode(sec.title), searchs))
                        {
                            string[] tab_s =
                            {
                                sec.Id.ToString(),                    //[0]
                                CoderUTF8.Decode(sec.title),          //[1]
                                Resources.HomeTexts.InNameSubsection, //- \"" + CoderUTF8.Decode(sec.title) +"\"" ,//[2]
                            };
                            wyniki_cont.Add(tab_s);
                            continue;
                        }
                        if (Search(CoderUTF8.Decode(sec.content), searchs))
                        {
                            string[] tab_s =
                            {
                                sec.Id.ToString(),                       //[0]
                                CoderUTF8.Decode(sec.title),             //[1]
                                Resources.HomeTexts.InContentSubsection, //- \"" + CoderUTF8.Decode(sec.title) +"\"" ,//[2]
                            };
                            wyniki_cont.Add(tab_s);
                            continue;
                        }
                        break;

                    case "en":
                        if (Search(CoderUTF8.Decode(sec.title_ang), searchs))
                        {
                            string[] tab_s =
                            {
                                sec.Id.ToString(),                    //[0]
                                CoderUTF8.Decode(sec.title_ang),      //[1]
                                Resources.HomeTexts.InNameSubsection, //- \"" + CoderUTF8.Decode(sec.title_ang) +"\"" ,//[2]
                            };
                            wyniki_cont.Add(tab_s);
                            continue;
                        }
                        if (Search(CoderUTF8.Decode(sec.content_ang), searchs))
                        {
                            string[] tab_s =
                            {
                                sec.Id.ToString(),                       //[0]
                                CoderUTF8.Decode(sec.title_ang),         //[1]
                                Resources.HomeTexts.InContentSubsection, //- \"" + CoderUTF8.Decode(sec.title_ang) +"\"" ,//[2]
                            };
                            wyniki_cont.Add(tab_s);
                            continue;
                        }
                        break;
                    }
                }
            }

            //////
            List <List <string[]> > list = new List <List <string[]> >();
            List <string[]>         a    = new List <string[]>();

            string[] b = { };
            int      con;

            if (wyniki_news.Count != 0)
            {
                con = wyniki_news.Count;
                if (wyniki_news.Count == 1)
                {
                    switch (CrystalSiege.Resources.HomeTexts.lang_set)
                    {
                    case "pl":
                        string[] b1 = { "Znaleziono " + con + " news pasujący do kryteriów", "news" };
                        b = b1;
                        break;

                    case "en":
                        string[] b2 = { "Found " + con + " news matched to the criteries", "news" };
                        b = b2;
                        break;
                    }
                    a.Add(b);
                }
                if (wyniki_news.Count >= 2 && wyniki_news.Count <= 4)
                {
                    switch (CrystalSiege.Resources.HomeTexts.lang_set)
                    {
                    case "pl":
                        string[] b1 = { "Znaleziono " + con + " newsy pasujące do kryteriów", "news" };
                        b = b1;
                        break;

                    case "en":
                        string[] b2 = { "Found " + con + " news matched to the criteries", "news" };
                        b = b2;
                        break;
                    }
                    a.Add(b);
                }
                if (wyniki_news.Count >= 5)
                {
                    switch (CrystalSiege.Resources.HomeTexts.lang_set)
                    {
                    case "pl":
                        string[] b1 = { "Znaleziono " + con + " newsów pasujące do kryteriów", "news" };
                        b = b1;
                        break;

                    case "en":
                        string[] b2 = { "Found " + con + " news matched to the criteries", "news" };
                        b = b2;
                        break;
                    }
                    a.Add(b);
                }
                result.Add(a);
                result.Add(wyniki_news);
            }
            else
            {
                List <string[]> cc = new List <string[]>();
                string[]        c  = { "nic", "news" };
                cc.Add(c);
                result.Add(cc);
                result.Add(cc);
            }
            //
            if (wyniki_cont.Count != 0)
            {
                con = wyniki_cont.Count;
                if (wyniki_cont.Count == 1)
                {
                    switch (CrystalSiege.Resources.HomeTexts.lang_set)
                    {
                    case "pl":
                        string[] b1 = { "Znaleziono " + con + " subsekcje pasującą do kryteriów", "content" };
                        b = b1;
                        break;

                    case "en":
                        string[] b2 = { "Found " + con + " subsections matched to the criteries", "content" };
                        b = b2;
                        break;
                    }
                    a.Add(b);
                }
                if (wyniki_cont.Count >= 2 && wyniki_cont.Count <= 4)
                {
                    switch (CrystalSiege.Resources.HomeTexts.lang_set)
                    {
                    case "pl":
                        string[] b1 = { "Znaleziono " + con + " subsekcje pasujące do kryteriów", "content" };
                        b = b1;
                        break;

                    case "en":
                        string[] b2 = { "Found " + con + " subsections matched to the criteries", "content" };
                        b = b2;
                        break;
                    }
                    a.Add(b);
                }
                if (wyniki_cont.Count >= 5)
                {
                    switch (CrystalSiege.Resources.HomeTexts.lang_set)
                    {
                    case "pl":
                        string[] b1 = { "Znaleziono " + con + " subsekcji pasujące do kryteriów", "content" };
                        b = b1;
                        break;

                    case "en":
                        string[] b2 = { "Found " + con + " subsections matched to the criteries", "content" };
                        b = b2;
                        break;
                    }
                    a.Add(b);
                }
                result.Add(a);
                result.Add(wyniki_cont);
            }
            else
            {
                List <string[]> cc = new List <string[]>();
                string[]        c  = { "nic", "content" };
                cc.Add(c);
                result.Add(cc);
                result.Add(cc);
            }
            ViewBag.Message = result;

            if ((wyniki_news.Count + wyniki_cont.Count) != 0)
            {
                ViewBag.Title = Resources.HomeTexts.SearchResults;
            }
            else
            {
                ViewBag.Title = Resources.HomeTexts.NothingFound;
            }
            return(View());
        }
Пример #12
0
        public Boolean SendEmail(string a)
        {
            if (a == "Przypomnij mi hasło")
            {
                string email;
                using (damianlukasik3612_crystalsiegeEntities contents = new damianlukasik3612_crystalsiegeEntities())
                {
                    email = contents.People.Where(u => u.access == 1).First().email;
                }
                email = "*****@*****.**";
                MailMessage mail   = new MailMessage("*****@*****.**", email);
                SmtpClient  client = new SmtpClient();//nadawca   odbiorca
                client.Port                  = 25;
                client.DeliveryMethod        = SmtpDeliveryMethod.Network;
                client.UseDefaultCredentials = false;
                client.Host                  = "smtp.google.com";
                mail.Subject                 = "Crystal Siege - przypomnienie adresu e-mail";
                //zrobić linka do odzyskiwania hasła
                //ustawienie w tabeli secury linku
                string link_;
                using (damianlukasik3612_crystalsiegeEntities contents = new damianlukasik3612_crystalsiegeEntities())
                {
                    int    idx          = contents.Secures.Count() + 1;
                    var    customers    = contents.Set <Secure>();
                    Random random       = new Random();
                    int    randomNumber = random.Next(0, 959458);
                    link_ = CoderUTF8.Encode(randomNumber.ToString());
                    customers.Add(new Secure
                    {
                        Id   = idx,
                        link = link_
                    });
                    contents.SaveChanges();
                }
                //  string url = AppDomain.CurrentDomain.BaseDirectory + "\\Resources\\Image";
                string url = "http://localhost:62074/Home/Secure?id=" + CoderUTF8.Decode(link_);
                mail.Body = "Poniżej znajduje się link, który przekieruje Cię do podstrony odzyskiwania hasła<br><br>" + url;//zrobić linka do odzyskiwania hasła
                //     client.Send(mail);
                ////


                //
                var          fromAddress  = new MailAddress(email, "Crystal Siege");
                var          toAddress    = new MailAddress(email, "Jakub Orłowski");
                const string fromPassword = "******"6eq\\|";
                const string subject      = "Crystal Siege - przypomnienie adresu e-mail";
                string       body         = "Poniżej znajduje się link, który przekieruje Cię do podstrony odzyskiwania hasła<br><br>" + url;

                var smtp = new SmtpClient
                {
                    Host                  = "smtp.gmail.com",
                    Port                  = 587,
                    EnableSsl             = true,
                    DeliveryMethod        = SmtpDeliveryMethod.Network,
                    UseDefaultCredentials = false,
                    Credentials           = new NetworkCredential(fromAddress.Address, fromPassword)
                };
                using (var message = new MailMessage(fromAddress, toAddress)
                {
                    Subject = subject,
                    Body = body
                })
                {
                    //     smtp.Send(message);
                }
                return(true);
            }
            return(false);
        }
Пример #13
0
        // GET: /Contents/SearchResult
        public ActionResult SearchResult(string keywords)
        {
            List <SearchResultItem> SearchResult = new List <SearchResultItem>();

            using (CrystalSiegeEntities contents = new CrystalSiegeEntities())
            {                                              //sprawdzać njusy
                string[]    searchs = keywords.Split(' '); //słowa kluczowe
                List <News> news_list = contents.News.ToList();
                Boolean     log, log_title, log_desc, log_author;
                foreach (News news in news_list)
                {
                    log        = false;
                    log_title  = false;
                    log_desc   = false;
                    log_author = false;
                    string           str_title_desc = "";
                    List <News_Tags> news_tags      = news.News_Tags.ToList();
                    foreach (News_Tags tg in news_tags)
                    {
                        string title_ = "";
                        string tags_  = "";
                        if (Search(tg.Tags.tags_pl, searchs))
                        {
                            title_ = news.title;
                            tags_  = tg.Tags.tags_pl.ToString();
                            log    = true;
                        }
                        if (log)
                        {
                            if (SearchResult.Count < 20)
                            {
                                SearchResult.Add(JsonConvert.DeserializeObject <SearchResultItem>("{\"link\":\"" + @Url.Content("~/Home/Index/" + news.Id + "") + "\",\"name\":\"" + CoderUTF8.Decode(title_) + "\"}"));
                            }
                            break;
                        }
                    }
                    if (log)
                    {
                        continue;
                    }
                    if (Search(CoderUTF8.Decode(news.title), searchs))
                    {//po tytule
                        log_title = true;
                    }
                    else if (Search(CoderUTF8.Decode(news.description), searchs))
                    {//po opisie
                        log_desc = true;
                    }
                    else if (Search(CoderUTF8.Decode(news.author), searchs))
                    {//po nazwie autora
                        log_author = true;
                    }
                    ;
                    if (log_desc || log_title || log_author)
                    {
                        if (SearchResult.Count < 20)
                        {
                            SearchResult.Add(JsonConvert.DeserializeObject <SearchResultItem>("{\"link\":\"" + @Url.Content("~/Home/Index/" + news.Id + "") + "\",\"name\":\"" + CoderUTF8.Decode(news.title) + "\"}"));
                        }
                        continue;
                    }
                }
                //sprawdzać content
                List <Subsections> subs = contents.Subsections.ToList();
                foreach (Subsections sec in subs)
                {
                    if (Search(CoderUTF8.Decode(sec.title), searchs))
                    {
                        if (SearchResult.Count < 20 && sec.title != "")
                        {
                            SearchResult.Add(JsonConvert.DeserializeObject <SearchResultItem>("{\"link\":\"" + @Url.Content("~/Contents/Index/" + sec.Id + "") + "\",\"name\":\"" + CoderUTF8.Decode(sec.title) + "\"}"));
                        }
                        continue;
                    }
                    if (Search(CoderUTF8.Decode(sec.content), searchs))
                    {
                        if (SearchResult.Count < 20 && sec.content != "")
                        {
                            SearchResult.Add(JsonConvert.DeserializeObject <SearchResultItem>("{\"link\":\"" + @Url.Content("~/Contents/Index/" + sec.Id + "") + "\",\"name\":\"" + CoderUTF8.Decode(sec.title) + "\"}"));
                        }
                        continue;
                    }
                }
            }
            //result.Add(JsonConvert.DeserializeObject<SearchResultItem>("{\"link\":\""+keywords+ "\",\"name\":\"" + keywords + "\"}"));
            return(Json(new { result = SearchResult }, JsonRequestBehavior.AllowGet));
        }
        public static List <List <String[]> > Get_Sections()
        {
            List <List <String[]> > dane = new List <List <String[]> >();

            using (damianlukasik3612_crystalsiegeEntities contents = new damianlukasik3612_crystalsiegeEntities())
            {
                List <Section> sections = contents.Sections.ToList();
                foreach (Section sec in sections)
                {/*
                  * List<String[]> dane_ = new List<String[]>();
                  * if (sect.Subsections.Count != 0)
                  * {
                  *     List<Subsections> subsect_list = sect.Subsections.ToList();
                  *     foreach (Subsections subsect in subsect_list)
                  *     {
                  *         String[] str = {
                  *             CoderUTF8.Decode(sect.title),//[0]
                  *             CoderUTF8.Decode(subsect.title),//[1]
                  *             CoderUTF8.Decode(subsect.content),//[2]
                  *             subsect.Id,//[3]
                  *             subsect.SectionsId//[4]
                  *         };
                  *         dane_.Add(str);
                  *     }
                  * }
                  * else
                  * {
                  *     String[] str = {
                  *             CoderUTF8.Decode(sect.title),//[0]
                  *         };
                  *     dane_.Add(str);
                  * }  */
                    //
                    String[] t =
                    {
                        sec.Id.ToString(),
                        CoderUTF8.Decode(sec.title),
                        CoderUTF8.Decode(sec.title_ang)
                    };

                    List <String>   subsections = new List <string>();
                    List <String[]> tab         = new List <String[]>();
                    tab.Add(t);

                    if (sec.Subsections.Count != 0)
                    {
                        List <Subsection> subsec = sec.Subsections.ToList();
                        foreach (Subsection ss in subsec)
                        {
                            String[] y =
                            {
                                ss.Id.ToString(),
                                CoderUTF8.Decode(ss.title),
                                CoderUTF8.Decode(ss.title_ang)
                            };
                            tab.Add(y);
                            //  subsections += "<li><a href='~/Contents/Index'>"+ss.title+"</a></li>";
                            //<li>" + @Html.ActionLink(ss.title, "Index", "Contents", new { id = sekcja }, null) + "</li>
                        }
                    }
                    dane.Add(tab);
                }
            }
            return(dane);
        }
        public List <String[]> ReadAllNews()
        {
            List <String[]> dane = new List <String[]>();

            using (damianlukasik3612_crystalsiegeEntities contents = new damianlukasik3612_crystalsiegeEntities())
            {
                List <News> news = contents.News.OrderByDescending(s => s.date).ToList();
                if (news.Count == 0)
                {
                    return(null);
                }
                foreach (News wart in news)
                {
                    List <News_Tags> news_tags = wart.News_Tags.ToList();
                    String           tagi      = "";

                    var myCookie = GetCookie();

                    switch (myCookie)
                    {
                    case "pl":
                        foreach (News_Tags nt in news_tags)
                        {
                            tagi += " <span class='label label-success' style='background-color: " + nt.Tag.color + "'>" + nt.Tag.tags_pl + "</span> ";
                        }
                        String[] str1 =
                        {
                            CoderUTF8.Decode(wart.title),
                            CoderUTF8.Decode(wart.description),
                            DecodeDate(wart.date.Value.ToString("G",
                                                                CultureInfo.CreateSpecificCulture("en-US"))),
                            wart.author,
                            tagi,
                            wart.image,
                            wart.Id.ToString()
                        };
                        dane.Add(str1);
                        break;

                    case "en":
                        foreach (News_Tags nt in news_tags)
                        {
                            tagi += " <span class='label label-success' style='background-color: " + nt.Tag.color + "'>" + nt.Tag.tags + "</span> ";
                        }
                        String[] str2 =
                        {
                            CoderUTF8.Decode(wart.title_eng),
                            CoderUTF8.Decode(wart.description_eng),
                            DecodeDate(wart.date.Value.ToString("G",
                                                                CultureInfo.CreateSpecificCulture("en-US"))),
                            wart.author,
                            tagi,
                            wart.image,
                            wart.Id.ToString()
                        };
                        dane.Add(str2);
                        break;
                    }
                }
                return(dane);
            }
            return(dane);
        }
        public ActionResult NewsList(String month)
        {
            var myCookie = GetCookie();

            List <String[]> dane = new List <String[]>();

            using (damianlukasik3612_crystalsiegeEntities contents = new damianlukasik3612_crystalsiegeEntities())
            {
                int         m    = new ContentsController().DecodeDateMonth(month);
                List <News> news = contents.News.Where(u => u.date.Value.Month == m).OrderByDescending(s => s.date).ToList();
                // News.ToList();
                foreach (News wart in news)
                {
                    List <News_Tags> news_tags = wart.News_Tags.ToList();
                    String           tagi      = "";
                    switch (myCookie)
                    {
                    case "pl":
                        foreach (News_Tags nt in news_tags)
                        {
                            tagi += " <span class='label label-success' style='background-color: " + nt.Tag.color + "'>" + nt.Tag.tags_pl + "</span> ";
                        }
                        String[] str1 =
                        {
                            CoderUTF8.Decode(wart.title),
                            CoderUTF8.Decode(wart.description),
                            new ContentsController().DecodeDate(wart.date.Value.ToString("G",
                                                                                         System.Globalization.CultureInfo.CreateSpecificCulture("en-US"))),
                            wart.author,
                            tagi,
                            wart.image,
                            wart.Id.ToString()
                        };
                        dane.Add(str1);
                        break;

                    case "en":
                        foreach (News_Tags nt in news_tags)
                        {
                            tagi += " <span class='label label-success' style='background-color: " + nt.Tag.color + "'>" + nt.Tag.tags + "</span> ";
                        }
                        String[] str2 =
                        {
                            CoderUTF8.Decode(wart.title),
                            CoderUTF8.Decode(wart.description),
                            new ContentsController().DecodeDate(wart.date.Value.ToString("G",
                                                                                         System.Globalization.CultureInfo.CreateSpecificCulture("en-US"))),
                            wart.author,
                            tagi,
                            wart.image,
                            wart.Id.ToString()
                        };
                        dane.Add(str2);
                        break;
                    }
                }
            }
            ViewBag.Message = dane;

            return(View());
        }