Beispiel #1
0
 public App(IMongoDBService mongo, IPastebinService pastebin, IPastebinAnalyzerService pba, ILogger <App> log)
 {
     _mongo    = mongo;
     _pastebin = pastebin;
     _pba      = pba;
     _log      = log;
 }
        /// <summary>
        /// This method updates the user's photo. If the photo's hash already in the GridFSPhotoes,
        /// then we just need to return it's id, otherwise we upload the new file (user photo),
        /// and update the UserPhoto model.
        /// </summary>
        public async Task <ObjectId> UpdatePhotoAsync(Domain.UserPhoto.UserPhoto userPhoto,
                                                      byte[] newPhoto,
                                                      string fileName)
        {
            try
            {
                string photoHash = hashService.GetHash(newPhoto);
                var(checkResult, existingPhotoID) = CheckIfHashInPhotoes(userPhoto, photoHash);

                if (checkResult)
                {
                    return(existingPhotoID);
                }

                IMongoDBService <Domain.UserPhoto.UserPhoto> mongoDatabase =
                    (IMongoDBService <Domain.UserPhoto.UserPhoto>)database;

                await database.Connect().ConfigureAwait(false);

                ObjectId newPhotoID = await mongoDatabase.GridFS.AddFile(newPhoto, fileName).ConfigureAwait(false);

                userPhoto.GridFSPhotoes.Add(newPhotoID.ToString(), photoHash);
                userPhoto.CurrentPhotoID = newPhotoID;

                await database.Update(userPhoto).ConfigureAwait(false);

                return(newPhotoID);
            }
            catch (Exception ex)
            {
                exceptionLogger.Log(new ApplicationError(ex), LogLevel.Error, logConfiguration);
                throw new DatabaseException("Error occured while updating the photo");
            }
        }
 public Controller(IExcelPhotoURLGetterService excelPhotoURLGetter, IFileValidator fileValidator,
                   IPathCreator pathCreator, IImageDownloaderService imageDownloaderService, IResizeImageService resizeImageService,
                   IMongoDBService mongoDBService)
 {
     this.excelPhotoURLGetter    = excelPhotoURLGetter;
     this.fileValidator          = fileValidator;
     this.pathCreator            = pathCreator;
     this.imageDownloaderService = imageDownloaderService;
     this.resizeImageService     = resizeImageService;
     this.mongoDBService         = mongoDBService;
 }
        public async Task <byte[]> GetRawPhotoAsync(ObjectId gridFSPhotoID)
        {
            try
            {
                await database.Connect().ConfigureAwait(false);

                IMongoDBService <Domain.UserPhoto.UserPhoto> mongoDatabase = (IMongoDBService <Domain.UserPhoto.UserPhoto>)database;
                byte[] rawPhoto = await mongoDatabase.GridFS.GetFile(gridFSPhotoID).ConfigureAwait(false);

                return(rawPhoto);
            }
            catch (Exception ex)
            {
                exceptionLogger.Log(new ApplicationError(ex), LogLevel.Error, logConfiguration);
                throw new DatabaseException("The error occured while getting raw photo");
            }
        }
 public ConfiguracionProxyController(IMongoDBService mongoDBService, IRedisService redisService)
 {
     _mongoDBService = mongoDBService;
     _comunicador    = _mongoDBService.GetInstance <ConfiguracionProxyModel>(_mongoDBService.CollectionConfigProxy);
     _redisService   = redisService;
 }
 public GetSearchReportQueryHandler(IMongoDBService mongoDBService, IMapper mapper)
 {
     _mongoDBService = mongoDBService;
     _mapper         = mapper;
 }
 public GetSearchesByPeriodQueryHandler(IMongoDBService mongoDBService, IMapper mapper)
 {
     _mongoDBService = mongoDBService;
     _mapper         = mapper;
 }
 public DeleteSearchCommandHandlerTests()
 {
     _mongoDBService             = A.Fake <IMongoDBService>();
     _deleteSearchCommandHandler = new DeleteSearchCommandHandler(_mongoDBService);
 }
 public GetApiKeyQueryHandler(IMongoDBService mongoDBService, IMapper mapper)
 {
     _mongoDBService = mongoDBService;
     _mapper         = mapper;
 }
 public GetApiKeyQueryHandlerTests()
 {
     _mongoDBService        = A.Fake <IMongoDBService>();
     _mapper                = CreateMapper();
     _getApiKeyQueryHandler = new GetApiKeyQueryHandler(_mongoDBService, _mapper);
 }
Beispiel #11
0
 public PastebinAnalyzerService(IMongoDBService mongo, ILogger <PastebinAnalyzerService> log)
 {
     _mongo = mongo;
     _log   = log;
 }
Beispiel #12
0
 public CreateSearchCommandHandler(IMongoDBService mongoDBService)
 {
     _mongoDBService = mongoDBService;
 }
 public RuneScapeStoryTimeService(IRuneScapeKeyboardService rsks, IMongoDBService mongo)
 {
     _mongo = mongo;
     _rsks  = rsks;
 }
 public GetAllSearchesQueryHandler(IMongoDBService mongoDBService, IMapper mapper)
 {
     _mongoDBService = mongoDBService;
     _mapper         = mapper;
 }
Beispiel #15
0
 public GetSearchesByPeriodQueryHandlerTests()
 {
     _mongoDBService = A.Fake <IMongoDBService>();
     _mapper         = CreateMapper();
     _getSearchesByPeriodQueryHandler = new GetSearchesByPeriodQueryHandler(_mongoDBService, _mapper);
 }
 public UsuariosController(IMongoDBService mongoDBService)
 {
     _mongoDBService = mongoDBService;
     _comunicador    = _mongoDBService.GetInstance <UsuariosModel>(_mongoDBService.CollectionUsuarios);
 }
Beispiel #17
0
 public CreateSearchCommandHandlerTests()
 {
     _mongoDBService             = A.Fake <IMongoDBService>();
     _createSearchCommandHandler = new CreateSearchCommandHandler(_mongoDBService);
 }
 public MessageDeliveryController(IQManager _iqManager, IMongoDBService mongo)
 {
     iqManager = _iqManager;
     _mongo    = mongo;
 }
Beispiel #19
0
 public QueryHandler(IMongoDBService database)
 {
     _database = database;
 }
 public CommandHandler(IMongoDBService database)
 {
     _database = database;
 }
Beispiel #21
0
 public InfoReqResController(IMongoDBService mongoDBService, IRedisService redisService)
 {
     _mongoDBService = mongoDBService;
     _comunicador    = _mongoDBService.GetInstance <InfoReqResModel>(_mongoDBService.CollectionInfoReqRes);
     _redisService   = redisService;
 }
Beispiel #22
0
 public CommandHandler(IMongoDBService database,
                       IHandler <RegistrarPassagemPeloTerminal.Command, Task> registrarPassagemPeloTerminalHandler)
 {
     _database = database;
     _registrarPassagemPeloTerminalHandler = registrarPassagemPeloTerminalHandler;
 }