Example #1
0
        static protected void FileAdd(string type, string Fname, string folder)
        {
            Fname = Path.GetFileName(Fname);
            int  id_type = 0;
            bool IsHave  = false;

            CheckForTypes(type, ref IsHave, ref id_type);

            using (var pcFiles = new PcFiles())
            {
                foreach (var fol in pcFiles.MyFolders.ToList())
                {
                    if (folder == fol.Name)
                    {
                        if (IsHave == true)
                        {
                            var file = new MyFile {
                                Name = Fname, Id_type = id_type, Id_folder = fol.Id
                            };
                            pcFiles.Mies.Add(file);
                            pcFiles.SaveChanges();
                        }
                    }
                }
            }
        }
Example #2
0
 static protected void CheckForTypes(string type, ref bool have, ref int id_type)
 {
     using (PcFiles pcFiles = new PcFiles())
     {
         foreach (var myFile in pcFiles.MiesType.ToList())
         {
             if (type == myFile.Type)
             {
                 id_type = myFile.Id;
                 have    = true;
             }
         }
     }
 }
Example #3
0
 static protected void AddFolder(List <string> Foldes, string ppath)
 {
     using (var pcFiles = new PcFiles())
     {
         ppath = Path.GetDirectoryName(ppath);
         if (Foldes.Contains(ppath) == false)
         {
             var myFolder = new MyFolder {
                 Name = ppath
             };
             Foldrs.Add(ppath);
             pcFiles.MyFolders.Add(myFolder);
             pcFiles.SaveChanges();
         }
     }
 }
Example #4
0
        static protected void AddType(string type)
        {
            using (var pcFiles = new PcFiles())
            {
                bool IsHaveThisType = false;

                foreach (var my in pcFiles.MiesType.ToList())
                {
                    if (my.Type == type)
                    {
                        IsHaveThisType = true;
                    }
                }
                if (IsHaveThisType == false)
                {
                    var myFileType = new MyFileType {
                        Type = type
                    };
                    pcFiles.MiesType.Add(myFileType);
                    pcFiles.SaveChanges();
                }
            }
        }