public async Task SuccesfulDetelete() { var service = new ServiceCollection(); service.ConfigureKindOfIdentification(new DbSettings { ConnectionString = "Server = DESKTOP-QHO5U57\\MYSQLFORBLAZOR; Database=PersonsContactInfo;Trusted_Connection=True;" }); var provider = service.BuildServiceProvider(); var KindOfIdService = provider.GetRequiredService <IKindOfIdentificationService>(); var addedKindOfId = new KindOfIdentificationDto { KindOfIdentificationId = Guid.NewGuid(), IdentificationName = "RegistroCivil" }; await KindOfIdService.InsertKindOfId(addedKindOfId); var response = await KindOfIdService.DeleteKindOfIdentification(new KindOfIdentificationDto { KindOfIdentificationId = addedKindOfId.KindOfIdentificationId, IdentificationName = addedKindOfId.IdentificationName }); Assert.True(response); }
public async Task GetAllKindsOfId() { var service = new ServiceCollection(); service.ConfigureKindOfIdentification(new DbSettings { ConnectionString = "Server = DESKTOP-QHO5U57\\MYSQLFORBLAZOR; Database=PersonsContactInfo;Trusted_Connection=True;" }); var provider = service.BuildServiceProvider(); var KindOfIdService = provider.GetRequiredService <IKindOfIdentificationService>(); var AddedKindOfId = new KindOfIdentificationDto { KindOfIdentificationId = KindOfIdId, IdentificationName = "Registro Civil" }; await KindOfIdService.InsertKindOfId(AddedKindOfId); var response = KindOfIdService.GetKindOfId().Result.Any(); Assert.True(response); await KindOfIdService.DeleteKindOfIdentification(AddedKindOfId); }
public async Task <bool> UpdateKindOfId(KindOfIdentificationDto kindOfId) { var entityToUpdate = await _kindOfIdRepo.GetOne <KindOfIdentificationEntity>(x => x.KindOfIdentificationId == kindOfId.KindOfIdentificationId).ConfigureAwait(false); if (entityToUpdate != null) { entityToUpdate.IdentificationName = kindOfId.IdentificationName; await _kindOfIdRepo.Update(entityToUpdate); return(true); } throw new noExistingKindOfIdException("El area a actualizar no existe"); }
public async Task <bool> VerifyExisting(KindOfIdentificationDto KindOfIdDto) { var EmployeeExists = await _kindOfIdRepo.SearchMatching <KindOfIdentificationEntity>(x => x.IdentificationName == KindOfIdDto.IdentificationName); if (EmployeeExists.Any()) { return(true); } else { return(false); } }
public async Task <bool> InsertKindOfId(KindOfIdentificationDto kindOfId) { var areaA = _kindOfIdRepo.SearchMatching <KindOfIdentificationEntity>(x => x.KindOfIdentificationId == kindOfId.KindOfIdentificationId); var AreaToInsert = areaA.Result.Any(); if (AreaToInsert) { throw new AlreadyExistingKindOfIDException("El tipo de identificacion ya existe"); } await _kindOfIdRepo.Insert(new KindOfIdentificationEntity { KindOfIdentificationId = kindOfId.KindOfIdentificationId, IdentificationName = kindOfId.IdentificationName, }); return(true); }
public async Task <bool> DeleteKindOfIdentification(KindOfIdentificationDto kindOfId) { if (kindOfId.IdentificationName == null) { throw new DeniedDeleteNameNullException("Por favor Ingrese el nombre de la identificacion a eliminar"); } if (kindOfId.IdentificationName.ToUpper() == "CEDULA" || kindOfId.IdentificationName.ToUpper() == "PASAPORTE" || kindOfId.IdentificationName.ToUpper() == "NIT") { throw new DeleteDeniedKindOfIdImportantException("No puede eliminar una de las identificaciones fundamentales"); } var KindOfIdToDelete = await _kindOfIdRepo.GetOne <KindOfIdentificationEntity>(x => x.KindOfIdentificationId == kindOfId.KindOfIdentificationId).ConfigureAwait(false); if (KindOfIdToDelete != null) { await _kindOfIdRepo.Delete <KindOfIdentificationEntity>(KindOfIdToDelete); return(true); } throw new ArgumentNullException("La identificacion que intenta eliminar no existe"); }
public async Task <bool> UpdateKindOfIdentification(KindOfIdentificationDto kindOfIdentificationDto) => await _kindOfIdentificationService.UpdateKindOfId(kindOfIdentificationDto).ConfigureAwait(false);
public async Task <KindOfIdentificationDto> GetOne(KindOfIdentificationDto kindOfIdDto) { var areaA = await _kindOfIdRepo.GetOne <KindOfIdentificationEntity>(x => x.IdentificationName == kindOfIdDto.IdentificationName).ConfigureAwait(false); return(Mapper.Map <KindOfIdentificationDto>(areaA)); }