public async Task <ValidationModel <Burial> > InsertAsync(Burial newEntity, CancellationToken cancellationToken = default) { var validation = await burilValidation.InsertValidationAsync(newEntity, cancellationToken); if (!validation.IsValid) { return(validation); } newEntity.CreatedAt = DateTime.Now; newEntity.UpdatedAt = DateTime.Now; validation.Result = await dataBurial.InsertAsync(newEntity, cancellationToken); if (newEntity.Files is not null && !newEntity.Files.Count().Equals(0)) { var fileDatas = await fileHelper.SaveFileRange(newEntity.Files); foreach (var file in fileDatas) { var attachmentForm = new AttachmentBurial() { FilePath = file.FilePath, FileName = file.FileName, FileType = file.FileType, BurialId = validation.Result.Id }; await dataAttachmentBurial.InsertAsync(attachmentForm, cancellationToken); } } return(validation); }
public async Task InsertValidationAsync_Succes() { // Arrange MockData( isExistTypeVictim: false, isExistTypeVictimById: false ); var entity = GetTypeVictim( id: Guid.NewGuid(), name: "Test Name" ); // Act var result = await _validation.InsertValidationAsync(entity); // Assert Assert.Multiple(() => { Assert.IsEmpty(result.Errors); Assert.IsTrue(result.IsValid); }); }
public async Task InsertValidationAsync_Succes() { // Arrange MockData( isExistDutyStation: false, isExistDutyStationById: false ); var entity = GetDutyStation( id: Guid.NewGuid(), place: "Test Place" ); // Act var result = await _validation.InsertValidationAsync(entity); // Assert Assert.Multiple(() => { Assert.IsEmpty(result.Errors); Assert.IsTrue(result.IsValid); }); }
public async Task InsertValidationAsync_Succes() { // Arrange MockData( isExsitAttachmentBurial: false, isExsitBurial: false ); var entity = GetAttachmentBurial( id: Guid.NewGuid(), burialId: Guid.NewGuid(), file: GetFormFile() ); // Act var result = await _validation.InsertValidationAsync(entity); // Assert Assert.Multiple(() => { Assert.IsEmpty(result.Errors); Assert.IsTrue(result.IsValid); }); }
public async Task <ValidationModel <User> > InsertAsync(User newEntity, CancellationToken cancellationToken = default) { var validation = await userValidation.InsertValidationAsync(newEntity, cancellationToken); if (!validation.IsValid) { return(validation); } newEntity.CreatedAt = DateTime.Now; newEntity.UpdatedAt = DateTime.Now; validation.Result = await dataUser.InsertAsync(newEntity, cancellationToken); return(validation); }
public async Task <ValidationModel <BirthPlace> > InsertAsync(BirthPlace newEntity, CancellationToken cancellationToken = default) { var validation = await birthPlaceValidation.InsertValidationAsync(newEntity, cancellationToken); if (!validation.IsValid) { return(validation); } newEntity.CreatedAt = DateTime.Now; newEntity.UpdatedAt = DateTime.Now; validation.Result = await dataBirthPlace.InsertAsync(newEntity, cancellationToken); return(validation); }
public async Task <ValidationModel <TypeBurial> > InsertAsync(TypeBurial newEntity, CancellationToken cancellationToken = default) { var validation = await typeBurialValidation.InsertValidationAsync(newEntity, cancellationToken); if (!validation.IsValid) { return(validation); } newEntity.CreatedAt = DateTime.Now; newEntity.UpdatedAt = DateTime.Now; validation.Result = await dataTypeBurial.InsertAsync(newEntity, cancellationToken); return(validation); }
public async Task <ValidationModel <AttachmentBurial> > InsertAsync(AttachmentBurial newEntity, CancellationToken cancellationToken = default) { var validation = await attachmentBurialValidation.InsertValidationAsync(newEntity, cancellationToken); if (!validation.IsValid) { return(validation); } var fileData = await fileHelper.SaveFile(newEntity.File); newEntity.FilePath = fileData.FilePath; newEntity.FileName = fileData.FileName; newEntity.FileType = fileData.FileType; newEntity.CreatedAt = DateTime.Now; newEntity.UpdatedAt = DateTime.Now; validation.Result = await dataAttachmentBurial.InsertAsync(newEntity, cancellationToken); return(validation); }
public async Task InsertValidationAsync_Succes() { // Arrange MockData( isExistBurial: false, isExistBurialById: true, isExistTypeBurialById: true ); var entity = GetBurial( id: Guid.NewGuid(), numberBurial: 1234, location: "Test location", knownNumber: 10, unknownNumber: 10, year: 1950, latitude: 20.20, longitude: 20.20, description: "Test description", typeBurialId: Guid.NewGuid() ); // Act var result = await _validation.InsertValidationAsync(entity); // Assert Assert.Multiple(() => { Assert.IsEmpty(result.Errors); Assert.IsTrue(result.IsValid); }); }