public async Task <TMValidationResult> ValidateDeletionOfOwnerAsync(Guid id) { if (id == null) { throw new TMNotValidException(string.Format(ErrorMessages.PropertyIsRequired, nameof(id))); } TMValidationResult validationResult = new TMValidationResult() { IsValid = true }; string message = string.Empty; bool result = await context.OwnerRepository.FindIfOwnerHasBranchesAsync(id); if (result) { message = Resources.BankHasBranch; } else { result = await FindIfOwnerDependenciesExistAsync(id); message = Resources.BankHasTemplate; } validationResult.IsValid = !result; validationResult.ValidationMessage = message; return(validationResult); }
public async Task <TMValidationResult> ValidateCreationOrEditOfFormAsync(string formNr, Guid id) { if (string.IsNullOrEmpty(formNr)) { throw new TMNotValidException(string.Format(ErrorMessages.PropertyIsRequired, nameof(Form.FormNr))); } if (id == null) { throw new TMNotValidException(string.Format(ErrorMessages.PropertyIsRequired, nameof(Form.IdForm))); } TMValidationResult tmValidationResult = new TMValidationResult() { IsValid = true }; bool identicalFormNrExists = await context.FormRepository.CheckIfIdenticalFormNrExistAsync(formNr, id); if (identicalFormNrExists) { tmValidationResult.IsValid = false; tmValidationResult.ValidationMessage = ResourceFiles.Resources.FormInUse; } return(tmValidationResult); }
public async Task <TMValidationResult> ValidateDeletionOfFormAsync(Guid id) { TMValidationResult tmValidationResult = new TMValidationResult() { IsValid = true }; bool result = await context.AuftragRepository.CheckIfDependencyBetweenAuftragAndFormExistsAsync(id); if (result) { tmValidationResult.IsValid = false; tmValidationResult.ValidationMessage = ResourceFiles.Resources.FormInUseOfAuftrag; } return(tmValidationResult); }
public async Task <TMValidationResult> ValidateCreationOrEditOfOwnerAsync(Guid id, string ownerCode, string parentsOwnerCode, string ownersSystemCode) { if (string.IsNullOrEmpty(ownerCode)) { throw new TMNotValidException(string.Format(ErrorMessages.PropertyIsRequired, nameof(ownerCode))); } if (string.IsNullOrEmpty(ownersSystemCode)) { throw new TMNotValidException(string.Format(ErrorMessages.PropertyIsRequired, nameof(ownersSystemCode))); } string message = string.Empty; bool result = await context.OwnerRepository.IsOwnerCodeUniqueAsync(id, ownerCode); if (!result) { //Need translation message = "Bank Code already exists."; } if (!string.IsNullOrEmpty(parentsOwnerCode) && result) { Owner parentOwner = await context.OwnerRepository.FindOwnerByOwnerCodeAsync(parentsOwnerCode); if (parentOwner == null) { result = false; //Need translation message = "!Parent Bank does not exist.TODO TRANSLATE THIS!"; } else if (parentOwner.SystemCode != ownersSystemCode) { result = false; //Need translation message = "!Parent Bank belongs to other Mandant.TODO TRANSLATE THIS!"; } } TMValidationResult validationResult = new TMValidationResult(); validationResult.IsValid = result; validationResult.ValidationMessage = message; return(validationResult); }