public ImportService( ILockService lockService, CasterContext db, IIdentityResolver identityResolver) { _lockService = lockService; _db = db; _isAdmin = identityResolver.IsAdminAsync().Result; _userId = identityResolver.GetClaimsPrincipal().GetId(); }
public async Task <File> Handle(Command request, CancellationToken cancellationToken) { if (!(await _authorizationService.AuthorizeAsync(_user, null, new ContentDeveloperRequirement())).Succeeded) { throw new ForbiddenException(); } await ValidateEntities(request.DirectoryId, request.WorkspaceId); var file = _mapper.Map <Domain.Models.File>(request); file.Save(_user.GetId(), isAdmin: (await _identityResolver.IsAdminAsync()), bypassLock: true); await _db.Files.AddAsync(file, cancellationToken); await _db.SaveChangesAsync(cancellationToken); return(await _fileQuery.ExecuteAsync(file.Id)); }