Beispiel #1
0
        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));
        }
Beispiel #2
0
 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);
     }
 }
Beispiel #3
0
 public async Task Validate(ModuleServiceObject saveModuleServiceObject, CancellationToken token)
 {
     await this.ValidateIfOrganisationIdIsValid(saveModuleServiceObject, token);
 }