public override void Execute(List <CommandParameter> parameters) { var path = GetStringParameterValue(parameters, CommandPathParameter.Name); var name = GetStringParameterValue(parameters, CommandNameParameter.Name); var description = GetStringParameterValue(parameters, CommandDescriptionParameter.Name); if (StoredDataService.ExistsTemplate(name)) { throw new TemplateNameRepeatedException(); } if (!FileService.ExistsDirectory(path)) { throw new PathNotFoundException(path); } if (!FileService.ExistsTemplateConfigFile(path)) { throw new TemplateConfigFileNotFoundException(path); } if (!StringFormats.IsValidLogicalName(name)) { throw new InvalidStringFormatException("Name can only contains alphanumeric characters"); } StoredDataService.AddTemplate(path, name, description); Log($"Template stored!"); }
public override void Execute(List <CommandParameter> parameters) { var name = GetStringParameterValue(parameters, CommandNameParameter.Name); if (!StoredDataService.ExistsTemplate(name)) { throw new TemplateNotFoundException(); } StoredDataService.DeleteTemplate(name); Log($"Template deleted!"); }