Exemplo n.º 1
0
        public async Task <SpecialistModel> Handle(UpdateSpecialistCommand request, CancellationToken cancellationToken)
        {
            var specialist = await _repository.GetSpecialistByIdAsync(request.Id);

            specialist.Names          = request.Names;
            specialist.Surnames       = request.Surnames;
            specialist.LastModified   = DateTime.UtcNow;
            specialist.LastModifiedBy = "APPLICATION";

            long insertedId = await _repository.UpdateSpecialistAsync(specialist);

            specialist = await _repository.GetSpecialistByIdAsync(insertedId);

            return(new SpecialistModel()
            {
                Id = specialist.Id,
                Names = specialist.Names,
                Surnames = specialist.Surnames
            });
        }
        public async Task <SpecialistModel> Handle(GetSpecialistByIdQuery request, CancellationToken cancellationToken)
        {
            var specialist = await _repository.GetSpecialistByIdAsync(request.Id);

            return(new SpecialistModel()
            {
                Id = specialist.Id,
                Names = specialist.Names,
                Surnames = specialist.Surnames
            });
        }
        public async Task <SpecialistModel> Handle(DeleteSpecialistCommand request, CancellationToken cancellationToken)
        {
            var resultId = await _repository.DeleteSpecialistAsync(request.Id);

            var specialist = await _repository.GetSpecialistByIdAsync(resultId);

            return(new SpecialistModel()
            {
                Id = specialist.Id,
                Names = specialist.Names,
                Surnames = specialist.Surnames
            });
        }
Exemplo n.º 4
0
        public async Task <SpecialistModel> Handle(CreateSpecialistCommand request, CancellationToken cancellationToken)
        {
            long insertedId = await _repository.CreateSpecialistAsync(new Specialist()
            {
                Id        = request.Id,
                Names     = request.Names,
                Surnames  = request.Surnames,
                CreatedBy = "APPLICATION"
            });

            var specialist = await _repository.GetSpecialistByIdAsync(insertedId);

            return(new SpecialistModel()
            {
                Id = specialist.Id,
                Names = specialist.Names,
                Surnames = specialist.Surnames
            });
        }