Exemple #1
0
 public Task <IResult <TModel> > Handle(GetOne <TModel> request, CancellationToken cancellationToken)
 {
     return(Task.Run(() =>
     {
         return _uow.Execute(db => Result.Success(db.GetCollection <TModel>().FindById(request.Id)));
     }, cancellationToken));
 }
 public Task <IResult <IEnumerable <TModel> > > Handle(GetAll <TModel> request, CancellationToken cancellationToken)
 {
     return(Task.Run(() =>
     {
         return _uow.Execute(db => Result.Success(
                                 db.GetCollection <TModel>().FindAll()));
     }, cancellationToken));
 }
Exemple #3
0
 public Task <IResult <Append> > Handle(CreateMatch request, CancellationToken cancellationToken)
 {
     return(Task.Run(() =>
     {
         return _uow.Execute(db =>
         {
             var match = new Append
             {
                 SourceId = request.SourceId,
                 LookupId = request.LookupId,
                 Threshold = request.Threshold
             };
             db.GetCollection <Append>().Insert(match);
             return Result.Success(match);
         });
     }, cancellationToken));
 }
 public Task <IResult <DatasetFile> > Handle(GetDatasetFile request, CancellationToken cancellationToken)
 {
     return(Task.Run(() =>
     {
         return _uow.Execute(db =>
         {
             var dataset = db.GetCollection <Dataset>().FindById(request.Id);
             var stream = new MemoryStream();
             db.FileStorage.Download(dataset.FileId, stream);
             stream.Seek(0, SeekOrigin.Begin);
             return Result.Success(new DatasetFile
             {
                 Id = dataset.FileId,
                 Name = dataset.FileName,
                 Contents = stream
             });
         });
     }, cancellationToken));
 }
        public Task <IResult <Dataset> > Handle(CreateDataset request, CancellationToken cancellationToken)
        {
            return(Task.Run(() =>
            {
                return _uow.Execute(db =>
                {
                    var dataset = new Dataset
                    {
                        Name = request.Name
                    };
                    db.GetCollection <Dataset>().Insert(dataset);

                    var fileInfo =
                        db.FileStorage.Upload($"$/datasets/{dataset.Id}", request.FileName, request.FileStream);

                    dataset.FileId = fileInfo.Id;
                    dataset.FileName = fileInfo.Filename;

                    db.GetCollection <Dataset>().Update(dataset);

                    return Result.Success(dataset);
                });
            }, cancellationToken));
        }
Exemple #6
0
 private Append GetAppend(Int32 appendId)
 {
     return(_uow.Execute(db => db.GetCollection <Append>().FindById(appendId)));
 }