private void DeleteDBfile(NsiFileCashes fileCashes)
 {
     using (var db = _govDb.GetContext())
     {
         db.NsiFileCashes.Remove(fileCashes);
         db.SaveChanges();
     }
 }
 private void UpdateCasheFiles(NsiFileCashes fileCashes)
 {
     using (var db = _govDb.GetContext())
     {
         db.NsiFileCashes.Update(fileCashes);
         db.SaveChanges();
     }
 }
 private void SavePath(NsiFileCashes item)
 {
     try
     {
         using (var db = _govDb.GetContext())
         {
             db.NsiFileCashes.Add(item);
             db.SaveChanges();
         }
     }
     catch (Exception ex)
     {
         _logger.LogError(ex, ex.Message);
     }
 }
        bool GetDBfile(string FullPath)
        {
            NsiFileCashes find = null;

            using (var db = _govDb.GetContext())
            {
                find = db.NsiFileCashes
                       .AsNoTracking()
                       .Where(x => x.Full_path == FullPath)
                       .OrderByDescending(x => x.Date)
                       .FirstOrDefault();
            }
            if (find == null)
            {
                return(false);
            }
            else
            {
                return(true);
            }
        }
        private void SaveFTPPath(List <FtpListItem> ListFile, string ftpDir, string baseDir, Status status, FLType fz)
        {
            foreach (FtpListItem item in ListFile)
            {
                if (!GetDBfile(item.FullName))
                {
                    var filesave = new NsiFileCashes();
                    filesave.Date         = item.Modified;
                    filesave.Size         = item.Size;
                    filesave.Full_path    = item.FullName;
                    filesave.Zip_file     = item.Name;
                    filesave.BaseDir      = baseDir;
                    filesave.Dirtype      = ftpDir;
                    filesave.Fz_type      = fz;
                    filesave.Status       = status;
                    filesave.Modifid_date = DateTime.Now;

                    SavePath(filesave);
                }
            }
        }