Пример #1
0
 public async Task <IEnumerable <FileReference> > GetFilesForAuthorAsync(string authorName)
 {
     using (var db = new FileDbContext())
     {
         return(await db.FileReferences.Where(p => p.Author.Name == authorName).ToListAsync());
     }
 }
Пример #2
0
 public async static void SaveFileToDatabase(File fileModel)
 {
     using (var context = new FileDbContext())
     {
         context.Files.Add(fileModel);
         await context.SaveChangesAsync();
     }
 }
 public ReportProblemService(AppDbContext appDbContext, IMapper mapper, IEmailService emailService, IEncryptionManager encryption, FileDbContext fileDbContext, IUserIPAddress userIPAddress)
 {
     _appDbContext  = appDbContext;
     _mapper        = mapper;
     _emailService  = emailService;
     _fileDbContext = fileDbContext;
     _userIPAddress = userIPAddress;
 }
 public FileController(IFileService fileService, IOptions <MinIoConfig> minIoConfig, AppDbContext appDbContext, MongoDbContext mongoDbContext, FileDbContext fileDbContext)
 {
     _fileService    = fileService;
     _minIoConfig    = minIoConfig.Value;
     _appDbContext   = appDbContext;
     _mongoDbContext = mongoDbContext;
     _fileDbContext  = fileDbContext;
 }
Пример #5
0
 public async static void SaveStatusToDatabase(Status status)
 {
     using (var context = new FileDbContext())
     {
         context.Statuses.Add(status);
         await context.SaveChangesAsync();
     }
 }
 public FileService(IMapper mapper, FileDbContext fileDbContext, AppDbContext dbContext, IEncryptionManager encryption, IProfilePercentageCalculationService profilePercentageCalculation, MongoDbContext mongoDbContext, IUserIPAddress userIPAddress)
 {
     _mapper        = mapper;
     _fileDbContext = fileDbContext;
     _appDbContext  = dbContext;
     _encryption    = encryption;
     _profilePercentageCalculation = profilePercentageCalculation;
     _mongoDbContext = mongoDbContext;
     _userIPAddress  = userIPAddress;
 }
Пример #7
0
 public ActivityAndChallengesService(AppDbContext appDbContext, IMapper mapper, FileDbContext fileDbContext, IApplicationProgressStatusService applicationProgressService, MongoDbContext mongoDbcontext, IOptions <MinIoConfig> minIoConfig, IUserIPAddress userIPAddress)
 {
     _appDbContext  = appDbContext;
     _mapper        = mapper;
     _fileDbContext = fileDbContext;
     _applicationProgressService = applicationProgressService;
     _mongoDbcontext             = mongoDbcontext;
     _minIoConfig   = minIoConfig.Value;
     _userIPAddress = userIPAddress;
 }
 public ProgramService(AppDbContext appDbContext, IMapper mapper, FileDbContext fileDbContext, IApplicationProgressStatusService applicationProgressService, MongoDbContext mongoDbcontext, IEmailService emailService, IOptions <MinIoConfig> minIoConfig, IUserIPAddress userIPAddress)
 {
     _appDbContext  = appDbContext;
     _mapper        = mapper;
     _fileDbContext = fileDbContext;
     _applicationProgressService = applicationProgressService;
     _mongoDbcontext             = mongoDbcontext;
     _emailService  = emailService;
     _minIoConfig   = minIoConfig.Value;
     _userIPAddress = userIPAddress;
 }
Пример #9
0
 public IndexModel(ILogger <IndexModel> logger, FileDbContext fileDbContext,
                   DirectoryService directoryService,
                   FileService fileService,
                   FileSharedService fileSharedService)
 {
     _logger                = logger;
     this.fileDbContext     = fileDbContext;
     this.directoryService  = directoryService;
     this.fileService       = fileService;
     this.fileSharedService = fileSharedService;
 }
Пример #10
0
 public FilesController(ILogger <FilesController> logger,
                        MergingQueue mergingQueue,
                        FileDbContext dbContext,
                        IConfiguration configuration,
                        IMemoryCache memoryCache)
 {
     _logger        = logger;
     _mergingQueue  = mergingQueue;
     _dbContext     = dbContext;
     _configuration = configuration;
     _memoryCache   = memoryCache;
 }
        public void DeveRetornarArquivoNuloPorIdSeNaoExistir()
        {
            using (var context = new FileDbContext(GetDbContextOptions())) {
                context.Database.EnsureDeleted();
                context.Database.EnsureCreated();
                var fileS3Repository = new FileS3Repository(context);
                int invalidId        = 0;
                var fileS3Result     = fileS3Repository.GetById(invalidId);

                Assert.Null(fileS3Result);
            }
        }
        public void DeveRetornarListaVazia()
        {
            using (var context = new FileDbContext(GetDbContextOptions())) {
                context.Database.EnsureDeleted();
                context.Database.EnsureCreated();

                var fileS3Repository = new FileS3Repository(context);
                var fileS3Result     = fileS3Repository.GetAll();

                Assert.NotNull(fileS3Result);
                Assert.Equal(0, fileS3Result.Count);
            }
        }
        public void DeveSalvarComSucesso()
        {
            using (var context = new FileDbContext(GetDbContextOptions())) {
                context.Database.EnsureDeleted();
                context.Database.EnsureCreated();
                var fileS3Repository = new FileS3Repository(context);
                var fileS3           = GetNewRandomFileS3();

                var fileS3Result = fileS3Repository.Add(fileS3);

                Assert.NotNull(fileS3Result);
            }
        }
        public void DeveRetornarArquivoPorId()
        {
            using (var context = new FileDbContext(GetDbContextOptions())) {
                context.Database.EnsureDeleted();
                context.Database.EnsureCreated();
                var fileS3Repository = new FileS3Repository(context);
                var fileS3           = fileS3Repository.Add(GetNewRandomFileS3());

                var fileS3Result = fileS3Repository.GetById(fileS3.Id);

                Assert.NotNull(fileS3Result);
                Assert.Equal(fileS3.Id, fileS3Result.Id);
            }
        }
Пример #15
0
        public async Task <FileReference> InsertFileReferenceAsync(FileReference fileReference)
        {
            using (var db = new FileDbContext())
            {
                if (await db.FileReferences.AnyAsync(p => p.AuthorId == fileReference.Author.Id && p.Name == fileReference.Name))
                {
                    throw new FileReferenceAlreadyExistsException();
                }

                db.FileReferences.Add(fileReference);
                db.Entry(fileReference.Author).State = EntityState.Unchanged;
                var saved = await db.SaveChangesAsync();
            }
            return(fileReference);
        }
Пример #16
0
        public async Task <User> GetOrCreateUserAsync(string name)
        {
            using (var db = new FileDbContext())
            {
                var dbUser = await db.Users.FirstOrDefaultAsync(p => p.Name == name);

                if (dbUser == null)
                {
                    dbUser = new User {
                        Name = name
                    };
                    db.Users.Add(dbUser);
                    await db.SaveChangesAsync();
                }
                return(dbUser);
            }
        }
Пример #17
0
        public Main()
        {
            InitializeComponent();

            noteContext = new NoteDbContext();
            fileContext = new FileDbContext();

            InitNavigate();

            tree_Navi.MouseClick             += NoteOPerate;
            Main_Container.Panel2.MouseClick += MouseClick;
            btn_addFile.Click += addFile;
            btn_delFile.Click += delFile;

            btn_newNote.Click += newNote;
            btn_delNote.Click += delNote;
            btnSave.Click     += Save;
        }
        public void DeveRetornarTodosRegistros()
        {
            using (var context = new FileDbContext(GetDbContextOptions())) {
                context.Database.EnsureDeleted();
                context.Database.EnsureCreated();
                var fileS3Repository = new FileS3Repository(context);

                List <FileS3> files = new List <FileS3>();
                files.Add(fileS3Repository.Add(GetNewRandomFileS3()));
                files.Add(fileS3Repository.Add(GetNewRandomFileS3()));
                files.Add(fileS3Repository.Add(GetNewRandomFileS3()));

                var fileS3Result = fileS3Repository.GetAll();

                Assert.NotNull(fileS3Result);
                Assert.Equal(files.Count, fileS3Result.Count);
            }
        }
        public void DeveAtualizarArquivo()
        {
            using (var context = new FileDbContext(GetDbContextOptions())) {
                context.Database.EnsureDeleted();
                context.Database.EnsureCreated();
                var    fileS3Repository = new FileS3Repository(context);
                var    fileS3           = fileS3Repository.Add(GetNewRandomFileS3());
                string newBucketName    = "new-bucket-name";
                string newFileName      = "new-filename.png";
                string mimeType         = "image/png";
                fileS3.SetBucketName(newBucketName);
                fileS3.SetFileName(newFileName);
                fileS3.SetFilePath(newFileName);
                fileS3.SetContentType(mimeType);

                var fileS3Result = fileS3Repository.Update(fileS3);

                Assert.NotNull(fileS3Result);
                Assert.Equal(newBucketName, fileS3Result.BucketName);
            }
        }
Пример #20
0
 public FilesController(FileDbContext context, IHostingEnvironment appEnvironment)
 {
     app          = appEnvironment;
     this.context = context;
 }
Пример #21
0
 public DatabaseApiController(FileDbContext context, IWebHostEnvironment webHostEnvironment)
 {
     FileDbContext           = context;
     this.webHostEnvironment = webHostEnvironment;
 }
 public FileController(ILogger <FileController> logger, FileServConfig config, FileDbContext dbContext)
 {
     _log     = logger;
     _config  = config;
     _context = dbContext;
 }
Пример #23
0
 public FileEntityService(FileDbContext context)
 {
     _context = context;
 }
Пример #24
0
 public FileS3Repository(FileDbContext context)
 {
     _context = context;
 }
Пример #25
0
 public DirectoryService(FileDbContext fileDbContext, IHttpContextAccessor httpContextAccessor)
 {
     this.fileDbContext = fileDbContext;
     userId             = httpContextAccessor.HttpContext.User?.Claims.FirstOrDefault(e => e.Type == "sub")?.Value;
 }
Пример #26
0
 public GenericRepository(FileDbContext context)
 {
     _dbSet = context.Set <TEntity>();
 }
 public MovieRepository(FileDbContext _db)
 {
     this.db = _db;
 }
Пример #28
0
 public FileManager(FileDbContext context)
 {
     _context = context;
 }
Пример #29
0
 public FileRepository(FileDbContext fileDbContext)
 {
     this._fileDbContext = fileDbContext;
 }
Пример #30
0
 public TokenController(IConfiguration config, FileDbContext fileDbContext)
 {
     _configuration = config;
     _fileDbContext = fileDbContext;
 }