private string ValidateRemoveCommandTemplateModel(RemoveCommandTemplateModel model) { ValidateId(model.CommandTemplateId, nameof(model.CommandTemplateId)); ValidationResult sessionCodeValidation = new SessionCodeValidator(model.SessionCode).Validate(); if (!sessionCodeValidation.IsValid) { _messageBuilder.AppendLine(sessionCodeValidation.Message); } return(_messageBuilder.ToString()); }
public override ValidationResult Validate() { string message = _validationObject switch { CreateCommandTemplateModel ext => ValidateCreateCommandTemplateModel(ext), ModifyCommandTemplateModel ext => ValidateModifyCommandTemplateModel(ext), RemoveCommandTemplateModel ext => ValidateRemoveCommandTemplateModel(ext), _ => string.Empty }; return(new ValidationResult(string.IsNullOrEmpty(message), message)); }
public IActionResult RemoveCommandTemplate(RemoveCommandTemplateModel model) { try { _logger.LogDebug($"Endpoint: \"Management\" Method: \"RemoveCommandTemplate\""); ValidationResult validationResult = new ManagementValidator(model).Validate(); if (!validationResult.IsValid) { ExceptionHandler.ThrowProperExternalException(new InputValidationException(validationResult.Message)); } return(Ok(_service.RemoveCommandTemplate(model.CommandTemplateId, model.SessionCode))); } catch (Exception e) { return(BadRequest(e.Message)); } }