Beispiel #1
0
        public ActionResult Image(int id, bool miniature)
        {
            Soubory[] soubory = Session[SESSION_GALLERY] as Soubory[];

            if (soubory == null)
            {
                return(null);
            }

            byte[] data;

            if (miniature)
            {
                data = GalleryCache.ReadImage(id);

                if (data == null)
                {
                    data = new SkolaSoapClient().SouborGetMiniatura(id);
                    GalleryCache.SaveImage(id, data);
                }
            }
            else
            {
                data = new SkolaSoapClient().SouborGet(id).data;
            }

            Soubory soubor = soubory.FirstOrDefault(s => s.Id == id);

            if (soubor == null)
            {
                return(null);
            }

            string nazev    = soubor.nazev.ToLower();
            string mimeType = "image/";

            if (nazev.EndsWith(".jpg") || nazev.EndsWith(".jpeg"))
            {
                mimeType += "jpeg";
            }
            else if (nazev.EndsWith(".png"))
            {
                mimeType += "png";
            }

            return(File(data, mimeType));
        }
Beispiel #2
0
 public ActionResult Index()
 {
     ViewBag.NavigationLog   = Logger.GetNavigationLog().Replace("\n", "<br/>");
     ViewBag.CachedFileNames = GalleryCache.GetCachedFileNames();
     return(View());
 }