Example #1
0
        public List <Kronika106.FileSystemModel.Year> LoadYears()
        {
            if (!IsPostBack)
            {
                List <Kronika106.FileSystemModel.Year> lstRoky = new List <FileSystemModel.Year>();
                var directiories = Directory.EnumerateDirectories(Server.MapPath(GlobalConstants.PthFileSystemRoot));
                using (var _db = new Kronika106DBContext())
                {
                    foreach (var dir in directiories)
                    {
                        Kronika106.FileSystemModel.Year yr = new FileSystemModel.Year();
                        yr.Rok = Path.GetFileName(dir);

                        yr.PocetKomentarov = _db.Forum.Count(c => c.EventId.StartsWith(yr.Rok));

                        string descPath = Path.Combine(dir, GlobalConstants.fnRokPopisShort);
                        if (File.Exists(descPath))
                        {
                            yr.Popis = File.ReadAllText(descPath);
                        }
                        yr.PathFotka = string.Format("{0}/{1}/{2}", GlobalConstants.PthFileSystemRoot, yr.Rok, GlobalConstants.fnRokFotka);
                        lstRoky.Add(yr);
                    }
                }
                return(lstRoky);
            }
            return(null);
        }
Example #2
0
 // The id parameter should match the DataKeyNames value set on the control
 // or be decorated with a value provider attribute, e.g. [QueryString]int id
 public Kronika106.FileSystemModel.Year yearDetail_GetItem([QueryString("ID")] string yearId)
 {
     if (!IsPostBack)
     {
         if (!string.IsNullOrEmpty(yearId))
         {
             Kronika106.FileSystemModel.Year yr = new FileSystemModel.Year();
             string yearPath = string.Format("{0}/{1}", GlobalConstants.PthFileSystemRoot, yearId);
             string descPath = Path.Combine(Server.MapPath(yearPath), GlobalConstants.fnRokPopis);
             yr.Rok = yearId;
             if (File.Exists(descPath))
             {
                 yr.Popis = File.ReadAllText(descPath);
             }
             else
             {
                 yr.Popis = GlobalConstants.EmptyPopis;
             }
             return(yr);
         }
     }
     return(null);
 }