コード例 #1
0
        public async Task <bool> SalvarResponsavel(ResponsavelViewModel responsavelVM)
        {
            try
            {
                var responsavel = Mapper.Map <Responsavel>(responsavelVM);
                if (responsavel.Id == 0)
                {
                    await BeginTransaction();

                    await Task.Run(() => _responsavelRepository.Add(responsavel));
                    await Commit();

                    await _usuarioApplicationService.ValidarExistenciaUsuario(responsavel.Telefone, "Responsavel");
                }
                else
                {
                    await BeginTransaction();

                    await Task.Run(() => _responsavelRepository.Update(responsavel));
                    await Commit();
                }
                return(true);
            }
            catch (Exception e)
            {
                throw e;
            }
        }
コード例 #2
0
        public async override Task <Guid> HandleAsync(CreateResponsavelCommand request)
        {
            var newReponsavel = Responsavel.Create(request.Nome, request.CPF, request.Email, request.Foto);

            _repository.Add(newReponsavel);
            await _repository.SaveChangesAsync();

            return(newReponsavel.ID);
        }