Exemplo n.º 1
0
        public bool CreateFile(File file)
        {
            try
            {
                CatalogDatabaseDataContext context  = new WorkLinqToSql.CatalogDatabaseDataContext();
                WorkLinqToSql.Document     document = new WorkLinqToSql.Document();
                document.UserAuthor   = file.AuthorID;
                document.Status       = (int)Record.StatusType.PREMODERATION;
                document.MachineID    = file.RecordID;
                document.PathToFile   = file.PachToFile;
                document.DocumentName = file.DocumentName;
                document.DocumentType = file.DocumentType;
                document.FileName     = file.FileName;
                document.FileType     = file.FileType;
                document.Size         = file.Size;
                document.MachineID    = file.RecordID;

                context.Document.InsertOnSubmit(document);
                context.Document.Context.SubmitChanges();
            }
            catch
            {
                return(false);
            }

            return(true);
        }
Exemplo n.º 2
0
        public File ToFile(WorkLinqToSql.Document document)
        {
            string userName = "******";

            try
            {
                CatalogDatabaseDataContext context = new CatalogDatabaseDataContext();
                var author = (from user in context.AspNetUsers where (document.UserAuthor == user.Id) select user).Single();
                userName = author.FirstName + author.LastName;
            }
            catch { }
            CatalogAppMVC.Models.File file = new File(document.Id, document.UserAuthor, document.DocumentName, document.DocumentType, document.FileName, document.FileType, document.Size, document.PathToFile);

            return(file);
        }
Exemplo n.º 3
0
 public bool RemoveFile(int fileID)
 {
     try
     {
         CatalogDatabaseDataContext context = new CatalogDatabaseDataContext();
         WorkLinqToSql.Document     doc     = (from file in context.Document where file.Id == fileID select file).Single <WorkLinqToSql.Document>();
         context.Document.DeleteOnSubmit(doc);
         context.Document.Context.SubmitChanges();
     }
     catch
     {
         return(false);
     }
     return(true);
 }