public Task <bool> Delete(TipoDocumentoRequestDto requestDto)
        {
            ValidationDto(requestDto);
            var entity = ValidationEntity(requestDto);

            return(_tipoDocumentoRepositorio.Delete(entity));
        }
        public async void TipoDocumento_Update_Test_IntegrationTest()
        {
            ServiceProvider provider = ServiceCollectionTipoDocumento();

            var tipoDocumentoService = provider.GetRequiredService <ITipoDocumentoService>();
            var areaRepositorio      = provider.GetRequiredService <ITipoDocumentoRepositorio>();

            var dtoTipoDocumento = new TipoDocumentoRequestDto
            {
                Id = Guid.NewGuid(),
                NombreTipoDocumento = "FakeListTipoDocumentoUpdateI1",
            };

            var area = areaRepositorio
                       .SearchMatching <TipoDocumentoEntity>(x => x.NombreTipoDocumento == dtoTipoDocumento.NombreTipoDocumento)
                       .FirstOrDefault();

            if (area != null || area != default)
            {
                _ = await areaRepositorio.Delete(area).ConfigureAwait(false);
            }

            _ = await tipoDocumentoService.Insert(dtoTipoDocumento).ConfigureAwait(false);

            var dtoTipoDocumento2 = new TipoDocumentoRequestDto
            {
                Id = dtoTipoDocumento.Id,
            };
            var result = await tipoDocumentoService.Update(dtoTipoDocumento2).ConfigureAwait(false);

            Assert.True(result);

            _ = await tipoDocumentoService.Delete(dtoTipoDocumento).ConfigureAwait(false);
        }
        public Task <TipoDocumentoDto> Get(TipoDocumentoRequestDto requestDto)
        {
            ValidationDto(requestDto);
            var entity = ValidationEntity(requestDto);

            return(Task.FromResult(_mapper.Map <TipoDocumentoDto>(entity)));
        }
Ejemplo n.º 4
0
        public async void Cliente_GetAll_Test_IntegrationTest()
        {
            ServiceProvider provider = ServiceCollectionCliente();

            var clienteService     = provider.GetRequiredService <IClienteService>();
            var clienteRepositorio = provider.GetRequiredService <IClienteRepositorio>();
            var mapper             = provider.GetRequiredService <IMapper>();
            var documentoService   = provider.GetRequiredService <ITipoDocumentoService>();
            var documentoRepo      = provider.GetRequiredService <ITipoDocumentoRepositorio>();

            var dtoDocumento = new TipoDocumentoRequestDto
            {
                Id = Guid.NewGuid(),
                NombreTipoDocumento = "fakeDocumentofakeCliente03",
            };
            var documento = documentoRepo
                            .SearchMatching <TipoDocumentoEntity>(x => x.NombreTipoDocumento == dtoDocumento.NombreTipoDocumento || x.Id == dtoDocumento.Id)
                            .FirstOrDefault();

            if (documento != null || documento != default)
            {
                _ = await documentoRepo.Delete(documento).ConfigureAwait(false);
            }

            _ = await documentoService.Insert(dtoDocumento).ConfigureAwait(false);

            var dtoCliente = new ClienteRequestDto
            {
                Id                  = Guid.Parse("45c2a9b5-1eac-48d3-83a4-ff692326e4f7"),
                Nombre              = "NombreClienteGetAll",
                Apellido            = "NombreClienteGetAll",
                NumeroTelefono      = 123456789,
                CorreoElectronico   = "*****@*****.**",
                CodigoTipoDocumento = "000000008",
                TipoPersona         = (global::Evaluacion.Aplicacion.Dto.Especificas.Personas.TipoPersona)TipoPersona.Juridico,
                FechaNacimiento     = DateTimeOffset.Now,
                FechaRegistro       = DateTimeOffset.Now,
                TipoDocumentoId     = dtoDocumento.Id,
            };

            var cliente = clienteRepositorio
                          .SearchMatching <ClienteEntity>(x => x.Nombre == dtoCliente.Nombre || x.Id == dtoCliente.Id)
                          .FirstOrDefault();

            if (cliente != null || cliente != default)
            {
                _ = await clienteRepositorio.Delete(cliente).ConfigureAwait(false);
            }

            _ = await clienteService.Insert(dtoCliente).ConfigureAwait(false);

            var result = mapper.Map <IEnumerable <ClienteEntity> >(await clienteService.GetAll().ConfigureAwait(false));

            Assert.NotNull(result.ToString());
            Assert.True(result.Any());

            _ = await clienteService.Delete(dtoCliente).ConfigureAwait(false);

            _ = await documentoService.Delete(dtoDocumento).ConfigureAwait(false);
        }
 private static void ValidationDto(TipoDocumentoRequestDto requestDto)
 {
     if (requestDto == null)
     {
         throw new TipoDocumentoRequestDtoNullException();
     }
 }
Ejemplo n.º 6
0
        public async void TipoDocumento_GetAll_Test_IntegrationTest()
        {
            ServiceProvider provider = ServiceCollectionTipoDocumento();

            var tipoDocumentoService = provider.GetRequiredService <ITipoDocumentoService>();
            var areaRepositorio      = provider.GetRequiredService <ITipoDocumentoRepositorio>();
            var mapper = provider.GetRequiredService <IMapper>();

            var dtoTipoDocumento = new TipoDocumentoRequestDto
            {
                Id = Guid.NewGuid(),
                NombreTipoDocumento = "FakeListTipoDocumento1GetAll",
            };

            var area = areaRepositorio
                       .SearchMatching <TipoDocumentoEntity>(x => x.Id == dtoTipoDocumento.Id)
                       .FirstOrDefault();

            if (area != null || area != default)
            {
                _ = await areaRepositorio.Delete(area).ConfigureAwait(false);
            }

            _ = await tipoDocumentoService.Insert(dtoTipoDocumento).ConfigureAwait(false);

            var result = mapper.Map <IEnumerable <TipoDocumentoEntity> >(await tipoDocumentoService.GetAll().ConfigureAwait(false));

            Assert.NotNull(result.ToString());
            Assert.True(result.Any());

            _ = await tipoDocumentoService.Delete(dtoTipoDocumento).ConfigureAwait(false);
        }
Ejemplo n.º 7
0
        public async void Cliente_Delete_Test_IntegrationTest()
        {
            ServiceProvider provider = ServiceCollectionCliente();

            var clienteService     = provider.GetRequiredService <IClienteService>();
            var clienteRepositorio = provider.GetRequiredService <IClienteRepositorio>();
            var documentoService   = provider.GetRequiredService <ITipoDocumentoService>();
            var documentoRepo      = provider.GetRequiredService <ITipoDocumentoRepositorio>();

            var dtoDocumento = new TipoDocumentoRequestDto
            {
                Id = Guid.NewGuid(),
                NombreTipoDocumento = "fakeDocumentofakeCliente01",
            };
            var documento = documentoRepo
                            .SearchMatching <TipoDocumentoEntity>(x => x.NombreTipoDocumento == dtoDocumento.NombreTipoDocumento || x.Id == dtoDocumento.Id)
                            .FirstOrDefault();

            if (documento != null || documento != default)
            {
                _ = await documentoRepo.Delete(documento).ConfigureAwait(false);
            }

            _ = await documentoService.Insert(dtoDocumento).ConfigureAwait(false);

            var dtoCliente = new ClienteRequestDto
            {
                Id                  = Guid.NewGuid(),
                Nombre              = "fakeProveedorDeleteTestI1",
                Apellido            = "fakeProveedorDeleteTestI1",
                NumeroTelefono      = 123456789,
                CorreoElectronico   = "*****@*****.**",
                CodigoTipoDocumento = "000000001",
                TipoPersona         = (global::Evaluacion.Aplicacion.Dto.Especificas.Personas.TipoPersona)TipoPersona.Juridico,
                FechaNacimiento     = DateTimeOffset.Now,
                FechaRegistro       = DateTimeOffset.Now,
                TipoDocumentoId     = dtoDocumento.Id,
            };

            var cliente = clienteRepositorio
                          .SearchMatching <ClienteEntity>(x => x.Nombre == dtoCliente.Nombre || x.Id == dtoCliente.Id)
                          .FirstOrDefault();

            if (cliente != null || cliente != default)
            {
                _ = await clienteRepositorio.Delete(cliente).ConfigureAwait(false);
            }

            _ = await clienteService.Insert(dtoCliente).ConfigureAwait(false);

            var dtoCliente2 = new ClienteRequestDto
            {
                Id = dtoCliente.Id
            };
            var result = await clienteService.Delete(dtoCliente2).ConfigureAwait(false);

            Assert.True(result);
            _ = await documentoService.Delete(dtoDocumento).ConfigureAwait(false);
        }
        private TipoDocumentoEntity ValidationEntity(TipoDocumentoRequestDto requestDto)
        {
            var entity = _tipoDocumentoRepositorio.SearchMatchingOneResult <TipoDocumentoEntity>(x => x.Id == requestDto.Id);

            if (entity == null || entity == default)
            {
                throw new TipoDocumentoNoExistException(requestDto.NombreTipoDocumento);
            }
            return(entity);
        }
        public async Task <IActionResult> Post(int id, TipoDocumentoRequestDto tipoDocumentoDto)

        {
            var tipoDocumento = _mapper.Map <TipoDocumentoRequestDto, TipoDocumento>(tipoDocumentoDto);
            await _service.AddTipoDocumento(tipoDocumento);

            var tipoDocumentoresponseDto = _mapper.Map <TipoDocumento, TipoDocumentoResponseDto>(tipoDocumento);
            var response = new ApiResponse <TipoDocumentoResponseDto>(tipoDocumentoresponseDto);

            return(Ok(response));
        }
        public async Task <TipoDocumentoResponseDto> TipoDocumentoManagementInsert(TipoDocumentoRequestDto requestDto)
        {
            var result = await _tipoDocumentoService.Insert(requestDto).ConfigureAwait(false) != default;

            return(new TipoDocumentoResponseDto
            {
                Aceptado = result,
                StatusCode = result ? HttpStatusCode.OK : HttpStatusCode.Unauthorized,
                StatusDescription = result ? "Insert" : "No insert"
            });
        }
        public async Task <IActionResult> Put(int id, TipoDocumentoRequestDto tipoDocumentoDto)
        {
            var tipoDocumento = _mapper.Map <TipoDocumento>(tipoDocumentoDto);

            tipoDocumento.Id        = id;
            tipoDocumento.UpdateAt  = DateTime.Now;
            tipoDocumento.UpdatedBy = 2;
            _service.UpdateTipoDocumento(tipoDocumento);
            var response = new ApiResponse <bool>(true);

            return(Ok(response));
        }
        public Task <bool> Update(TipoDocumentoRequestDto requestDto)
        {
            ValidationDto(requestDto);
            var entity = ValidationEntity(requestDto);

            if (!string.IsNullOrEmpty(requestDto.NombreTipoDocumento))
            {
                entity.NombreTipoDocumento = requestDto.NombreTipoDocumento;
            }

            return(_tipoDocumentoRepositorio.Update(entity));
        }
        public async Task <Guid> Insert(TipoDocumentoRequestDto requestDto)
        {
            ValidationDto(requestDto);
            var usernameExist = _tipoDocumentoRepositorio
                                .SearchMatching <TipoDocumentoEntity>(x => x.NombreTipoDocumento == requestDto.NombreTipoDocumento)
                                .Any();

            if (usernameExist)
            {
                throw new TipoDocumentonameAlreadyExistException(requestDto.NombreTipoDocumento);
            }

            var response = await _tipoDocumentoRepositorio.Insert(_mapper.Map <TipoDocumentoEntity>(requestDto)).ConfigureAwait(false);

            return(response.Id);
        }
 public Task <TipoDocumentoDto> TipoDocumentoManagementGet(TipoDocumentoRequestDto requestDto)
 {
     return(_tipoDocumentoService.Get(requestDto));
 }
 public async Task <TipoDocumentoDto> GetTipoDocumento(TipoDocumentoRequestDto requestDto) =>
 await _fachadaGenericasService.TipoDocumentoManagementGet(requestDto).ConfigureAwait(false);
 public async Task <TipoDocumentoResponseDto> DeleteTipoDocumento(TipoDocumentoRequestDto requestDto) =>
 await _fachadaGenericasService.TipoDocumentoManagementDelete(requestDto).ConfigureAwait(false);
Ejemplo n.º 17
0
 public async Task<TipoDocumentoDto> Post(TipoDocumentoRequestDto tipoDocumentoDto) => await Post<TipoDocumentoRequestDto>("InsertTipoDocumento", tipoDocumentoDto).ConfigureAwait(false);