public static void Run(string solutionDirectory, string entityName, EntityProperty prop)
        {
            try
            {
                var propList = new List <EntityProperty>()
                {
                    prop
                };
                var srcDirectory    = Path.Combine(solutionDirectory, "src");
                var testDirectory   = Path.Combine(solutionDirectory, "tests");
                var projectBaseName = Utilities.SolutionGuard(solutionDirectory);

                EntityModifier.AddEntityProperties(srcDirectory, entityName, propList, projectBaseName);
                DtoModifier.AddPropertiesToDtos(srcDirectory, entityName, propList, projectBaseName);

                WriteHelpHeader($"{Environment.NewLine}The '{prop.Name}' property was successfully added to the '{entityName}' entity and its associated DTOs. Keep up the good work!");
            }
            catch (Exception e)
            {
                if (e is FileAlreadyExistsException ||
                    e is DirectoryAlreadyExistsException ||
                    e is InvalidSolutionNameException ||
                    e is FileNotFoundException ||
                    e is InvalidDbProviderException ||
                    e is InvalidFileTypeException ||
                    e is SolutionNotFoundException)
                {
                    WriteError($"{e.Message}");
                }
                else
                {
                    WriteError($"An unhandled exception occurred when running the API command.\nThe error details are: \n{e.Message}");
                }
            }
        }
Example #2
0
        public static void Run(string solutionDirectory, string entityName, EntityProperty prop)
        {
            try
            {
                GlobalSingleton instance = GlobalSingleton.GetInstance();

                var propList = new List <EntityProperty>()
                {
                    prop
                };

                EntityModifier.AddEntityProperties(solutionDirectory, entityName, propList);
                DtoModifier.AddPropertiesToDtos(solutionDirectory, entityName, propList);
                RepositoryModifier.AddInclude(solutionDirectory, entityName, propList);

                WriteHelpHeader($"{Environment.NewLine}The '{prop.Name}' property was successfully added to the '{entityName}' entity and it's associated DTOs. Keep up the good work!");
            }
            catch (Exception e)
            {
                if (e is FileAlreadyExistsException ||
                    e is DirectoryAlreadyExistsException ||
                    e is InvalidSolutionNameException ||
                    e is FileNotFoundException ||
                    e is InvalidDbProviderException ||
                    e is InvalidFileTypeException ||
                    e is SolutionNotFoundException)
                {
                    WriteError($"{e.Message}");
                }
                else
                {
                    WriteError($"An unhandled exception occurred when running the API command.\nThe error details are: \n{e.Message}");
                }
            }
        }