Exemplo n.º 1
0
        public static string ProcessSekce(BookSekce b, int iterace)
        {
            IList <BookSekce> list = new BookSekceDao().GetCategoriesDebug(b.Id);

            iterace++;

            foreach (BookSekce z in list)
            {
                ProcessSekce(z, iterace);
            }

            string toReturn = "";

            for (var i = 0; i < iterace; i++)
            {
                toReturn += "‌‌ ‌‌ ‌‌ ‌‌ ‌‌ ";
            }

            string tR = "";

            if (b.RenderPriority > 0)
            {
                tR = "[priority: " + b.RenderPriority.ToString() + "]";
            }

            textOutput.Add("<li>" + "<ul>" + toReturn + " > " + b.DebugName + " [id: " + b.Id.ToString() + "] " + tR + "</ul>" + "</li>");

            return("");
        }
Exemplo n.º 2
0
        public ActionResult UpdateSekce(int targetId, string text, HttpPostedFileBase picture)
        {
            BookSekce s = new BookSekceDao().GetbyId(targetId);

            s.Name = text;

            Image image     = Image.FromStream(picture.InputStream);
            Image smalImage = ImageHelper.ResizeImageHighQuality(image, 120, 120);

            Bitmap btmBitmap = new Bitmap(smalImage);
            Guid   guid      = Guid.NewGuid();

            string imageName = guid.ToString() + ".png";

            btmBitmap.Save(Server.MapPath("~/Uploads/Sekce/") + imageName,
                           ImageFormat.Png); // Je potřeba namapovat cestu!

            btmBitmap.Dispose();
            image.Dispose();

            s.ImageName = imageName;
            new BookSekceDao().Update(s);


            return(Redirect(Request.UrlReferrer.ToString()));
        }
Exemplo n.º 3
0
        public ActionResult AddSekce()
        {
            IList <BookSekce> list = new BookSekceDao().GetCategoriesDebug(null);


            return(View(list));
        }
Exemplo n.º 4
0
        public static string GetBookPath(int id)
        {
            // 1) Reverzně určíme cestu
            // --> Vezmeme aktuální kategorii příspěvku
            // --> Najdeme kategorii, která má jako potomka tuto kategorii
            // --> Opakujeme dokud p != -1
            // --> Na každé iteraci stavíme aktuální část cesty

            string outputString = "";

            BookDao      d        = new BookDao();
            BookSekceDao sekceDao = new BookSekceDao();

            Book prispevek    = d.GetbyId(id);
            bool dalsiIterace = true;

            BookSekce aktualniSekce = sekceDao.GetbyIdNull(prispevek.SectionId);

            outputString += aktualniSekce.DebugName + "/ ";

            while (dalsiIterace)
            {
                // Najdeme potomka sekce
                aktualniSekce = sekceDao.GetParentSekce(aktualniSekce.Id);
                outputString += aktualniSekce.DebugName + "/";
                if (aktualniSekce.ParentId <= 0)
                {
                    dalsiIterace = false;
                }
            }

            // 2) Teď máme cestu, ale reverzně
            // --> Konec cesty / Střed cesty / Začátek
            // --> Potřebujeme: Začátek / Střed / Konec
            // --> Rozdělíme string na tokeny
            // --> Reverzně dáme tokeny do správného pořadí

            string[] tokeny = outputString.Split('/');
            outputString = "";

            for (var i = tokeny.Length - 1; i >= 0; i--)
            {
                outputString += tokeny[i];

                // Vizuálně oddělujeme části cesty
                if (i > 0 && i != tokeny.Length - 1)
                {
                    outputString += " / ";
                }
            }

            return(outputString);
        }
Exemplo n.º 5
0
        public static List <BookSekce> GetCurrentCategories(int?currentCategory, string name)
        {
            BookSekceDao      dao  = new BookSekceDao();
            IList <BookSekce> list = dao.GetCategories(currentCategory);
            List <BookSekce>  l    = list as List <BookSekce>;

            l = l.OrderByDescending(o => o.RenderPriority).ToList();
            List <BookSekce> ll = new List <BookSekce>();

            foreach (BookSekce b in l)
            {
                if (General.AccessMatch(b.Restrikce, name))
                {
                    ll.Add(b);
                }
            }
            return(ll);
        }