Esempio n. 1
0
        public async Task <Unit> Handle(DeleteAgentProfileCommand request, CancellationToken cancellationToken)
        {
            var agentEntity            = _mapper.Map <AgentEntity>(request.Agent);
            AgentProfileEntity profile = await GetAgentProfile(agentEntity, request.ProfileId, cancellationToken);

            if (profile != null)
            {
                _context.AgentProfiles.Remove(profile);
            }

            return(await Unit.Task);
        }
Esempio n. 2
0
        public async Task <AgentProfileDocument> Handle(CreateAgentProfileCommand request, CancellationToken cancellationToken)
        {
            var agent = (AgentEntity)await _mediator.Send(MergeActorCommand.Create(request.Agent), cancellationToken);

            var profile = new AgentProfileEntity(request.Content, request.ContentType)
            {
                ProfileId = request.ProfileId,
                Agent     = agent
            };

            _context.AgentProfiles.Add(profile);
            await _context.SaveChangesAsync(cancellationToken);

            return(_mapper.Map <AgentProfileDocument>(profile));
        }
        public async Task <Unit> Handle(DeleteAgentProfileCommand request, CancellationToken cancellationToken)
        {
            AgentProfileEntity profile = await _context.Documents
                                         .OfType <AgentProfileEntity>()
                                         .AsNoTracking()
                                         .Where(x => x.AgentId == request.AgentId)
                                         .SingleOrDefaultAsync(x => x.Key == request.ProfileId, cancellationToken);

            if (profile != null)
            {
                _context.Documents.Remove(profile);
                await _context.SaveChangesAsync(cancellationToken);
            }

            return(await Unit.Task);
        }
Esempio n. 4
0
        public async Task <Unit> Handle(DeleteAgentProfileCommand request, CancellationToken cancellationToken)
        {
            var agentEntity = await _mediator.Send(GetAgentQuery.Create(request.Agent));

            if (agentEntity == null)
            {
                return(await Unit.Task);
            }

            AgentProfileEntity profile = await _context.AgentProfiles
                                         .AsNoTracking()
                                         .Where(x => x.AgentId == agentEntity.AgentId)
                                         .SingleOrDefaultAsync(x => x.ProfileId == request.ProfileId, cancellationToken);

            if (profile != null)
            {
                _context.AgentProfiles.Remove(profile);
                await _context.SaveChangesAsync(cancellationToken);
            }

            return(await Unit.Task);
        }