public async Task <ModuleServiceObject> UpdateModuleAsync(ModuleServiceObject moduleServiceObject, CancellationToken token) { await _saveModuleValidationService.Validate(moduleServiceObject, token); var moduleEntity = _mapper.Map <ModuleEntity>(moduleServiceObject); var updatedEntity = await _moduleRepository.UpdateModuleAsync(moduleEntity, token); return(_mapper.Map <ModuleServiceObject>(updatedEntity)); }
private async Task ValidateIfOrganisationIdIsValid(ModuleServiceObject moduleServiceObject, CancellationToken token) { try { await this._organisationRepository.GetOrganisationByIdAsync(moduleServiceObject.OrganisationId, token); } catch (Exception) { var validationError = new ValidationError { PropertyName = nameof(moduleServiceObject.OrganisationId), ErrorMessage = OrganisationIdShouldBeValidError }; throw new BadRequestException(validationError); } }
public async Task Validate(ModuleServiceObject saveModuleServiceObject, CancellationToken token) { await this.ValidateIfOrganisationIdIsValid(saveModuleServiceObject, token); }