public OutputObject GenerateWebServiceControllerClass(SqlTable sqlTable, List <string> namespaceIncludes, IDictionary <string, bool> options)
        {
            if (sqlTable == null)
            {
                throw new ArgumentException("Sql table cannot be null");
            }

            string class_name = NameFormatter.ToCSharpClassName(sqlTable.Name);

            var output = new OutputObject
            {
                Name = $"{class_name}Controller.cs",
                Type = OutputObject.eObjectType.CSharp
            };

            var sb = new StringBuilder();

            sb.AppendLine("using System;");
            sb.AppendLine("using System.Collections.Generic;");
            sb.AppendLine("using System.Reflection;");
            sb.AppendLine();
            sb.AppendLine("using Microsoft.AspNetCore.Mvc;");
            sb.AppendLine();

            if (namespaceIncludes != null && namespaceIncludes.Count > 1)
            {
                sb.AppendLine(GenerateNamespaceIncludes(namespaceIncludes));
            }

            sb.AppendLine($"namespace {CONTROLLER_NAMESPACE}.{NameFormatter.ToCSharpPropertyName(sqlTable.Database.Name)}");
            sb.AppendLine("{");

            sb.AppendLine(AddTabs(1) + "[ApiController]");

            if (options[GENERATE_BASE_CONTROLLER])
            {
                sb.AppendLine(AddTabs(1) + $"public class {sqlTable.Name}Controller : ControllerBase");
            }
            else
            {
                sb.AppendLine(AddTabs(1) + $"public class {sqlTable.Name}Controller : ApiController");
            }

            sb.AppendLine(AddTabs(1) + "{");

            sb.AppendLine(AddTabs(2) + $"public {sqlTable.Name}Controller() {{ }}");
            sb.AppendLine();

            // controllers
            sb.AppendLine(GenerateGetById(sqlTable.Name));
            sb.AppendLine();

            sb.AppendLine(GenerateGetAll(sqlTable.Name));
            sb.AppendLine();

            sb.AppendLine("}");

            output.Body = sb.ToString();
            return(output);
        }
        public OutputObject GenerateWebServiceControllerClass(SqlTable sqlTable, List <string> namespaceIncludes, IDictionary <string, bool> options)
        {
            if (sqlTable == null)
            {
                throw new ArgumentException("Sql table cannot be null");
            }

            string controllerName = NameFormatter.ToCSharpClassName(sqlTable.Name);

            var output = new OutputObject
            {
                Name = $"{controllerName}Controller.cs",
                Type = OutputObject.eObjectType.CSharp
            };

            var sb = new StringBuilder();

            sb.AppendLine();
            sb.AppendLine("using Microsoft.AspNetCore.Mvc;");
            sb.AppendLine("using System;");
            sb.AppendLine("using TelemetryManager;");
            sb.AppendLine();

            if (namespaceIncludes != null && namespaceIncludes.Count > 1)
            {
                sb.AppendLine(GenerateNamespaceIncludes(namespaceIncludes));
            }

            sb.AppendLine($"namespace {CONTROLLER_NAMESPACE}");
            sb.AppendLine("{");

            sb.AppendLine(AddTabs(1) + "[ApiController]");

            if (options[GENERATE_BASE_CONTROLLER])
            {
                sb.AppendLine(AddTabs(1) + $"public class {controllerName}Controller : ApiControllerBase");
            }
            else
            {
                sb.AppendLine(AddTabs(1) + $"public class {controllerName}Controller : ControllerBase");
            }

            sb.AppendLine(AddTabs(1) + "{");

            sb.AppendLine(AddTabs(2) + $"public {controllerName}Controller(IConfigProvider config, ILogger log, IMetrics metrics, IDataProvider datasource, ISecurityProvider security)");
            sb.AppendLine(AddTabs(3) + $": base(config, log, metrics, datasource, security) {{ }}");
            sb.AppendLine();

            // controllers
            sb.AppendLine(GenerateGetById(controllerName, options));
            sb.AppendLine();

            sb.AppendLine(GenerateGetAll(controllerName, options));
            sb.AppendLine();

            //sb.AppendLine(GenerateGetAllPaged(sqlTable.Name));
            //sb.AppendLine();

            //sb.AppendLine(GenerateInsert(sqlTable.Name));
            //sb.AppendLine();

            //sb.AppendLine(GenerateUpdate(sqlTable.Name));
            //sb.AppendLine();

            //sb.AppendLine(GenerateDelete(sqlTable.Name));
            //sb.AppendLine();

            sb.AppendLine("}");

            output.Body = sb.ToString();
            return(output);
        }
        public OutputObject GenerateWinformEditCode(SqlTable sqlTable)
        {
            #region Sample Output
            //using System;
            //using System.Collections.Generic;
            //using System.ComponentModel;
            //using System.Data;
            //using System.Drawing;
            //using System.Linq;
            //using System.Text;
            //using System.Windows.Forms;

            //namespace MarvelSuperheroesEditor
            //{
            //    public partial class Form1 : Form
            //    {
            //        public Form1()
            //        {
            //            InitializeComponent();
            //        }
            //    }
            //}
            #endregion

            if (sqlTable == null)
            {
                return(null);
            }

            string class_name = "frmEdit" + NameFormatter.ToCSharpPropertyName(sqlTable.Name);
            string dal_name   = NameFormatter.ToCSharpClassName("Dal" + sqlTable.Name);

            var output = new OutputObject
            {
                Name = class_name + ".cs",
                Type = OutputObject.eObjectType.CSharp
            };

            var sb = new StringBuilder();

            sb.AppendLine("using System;");
            sb.AppendLine("using System.Collections.Generic;");
            sb.AppendLine("using System.Configuration;");
            sb.AppendLine("using System.ComponentModel;");
            sb.AppendLine("using System.Data;");
            //sb.AppendLine("using System.Drawing;");
            //sb.AppendLine("using System.Linq;");
            //sb.AppendLine("using System.Text;");
            sb.AppendLine("using System.Windows.Forms;");
            sb.AppendLine();

            sb.AppendLine("using DAL;");
            sb.AppendLine("using " + NameFormatter.ToCSharpPropertyName(sqlTable.Database.Name) + ";");
            sb.AppendLine();

            sb.AppendLine("namespace " + NameFormatter.ToCSharpPropertyName(sqlTable.Database.Name) + "Editor");
            sb.AppendLine("{");

            sb.AppendLine(AddTabs(1) + "public partial class " + class_name + " : Form");
            sb.AppendLine(AddTabs(1) + "{");

            #region Fields
            sb.AppendLine(AddTabs(2) + "#region Fields");
            sb.AppendLine();
            sb.AppendLine(AddTabs(3) + "protected string _SQLConnection = ConfigurationManager.ConnectionStrings[\"SQLConnection\"].ConnectionString;");
            sb.AppendLine();
            sb.AppendLine(AddTabs(2) + "#endregion");
            sb.AppendLine();
            #endregion

            #region Methods
            sb.AppendLine(AddTabs(2) + "#region Methods");
            sb.AppendLine();

            sb.AppendLine(AddTabs(3) + "public " + class_name + "()");
            sb.AppendLine(AddTabs(3) + "{");
            sb.AppendLine(AddTabs(4) + "InitializeComponent();");
            sb.AppendLine();
            sb.AppendLine(AddTabs(4) + "LoadPopulateItemList();");
            sb.AppendLine(AddTabs(3) + "}");
            sb.AppendLine();

            sb.AppendLine(AddTabs(3) + "private bool LoadPopulateItemList()");
            sb.AppendLine(AddTabs(3) + "{");
            sb.AppendLine(AddTabs(4) + "this.Cursor = Cursors.WaitCursor;");
            sb.AppendLine();
            sb.AppendLine(AddTabs(4) + "try");
            sb.AppendLine(AddTabs(4) + "{");
            sb.AppendLine(AddTabs(5) + "" + dal_name + " dal = new " + dal_name + "(_SQLConnection);");
            sb.AppendLine();
            sb.AppendLine(AddTabs(5) + "if (dal.LoadAllFromDb())");
            sb.AppendLine(AddTabs(5) + "{");
            sb.AppendLine(AddTabs(6) + "if (dal.Collection != null && dal.Collection.Count != 0)");
            sb.AppendLine(AddTabs(6) + "{");
            sb.AppendLine(AddTabs(7) + "cboItemList.BeginUpdate();");
            sb.AppendLine(AddTabs(7) + "cboItemList.ValueMember     = \"" + FindIdField(sqlTable) + "\";");
            sb.AppendLine(AddTabs(7) + "cboItemList.DisplayMember   = \"" + FindNameField(sqlTable) + "\";");
            sb.AppendLine(AddTabs(7) + "cboItemList.DataSource      = dal.Collection;");
            sb.AppendLine(AddTabs(7) + "cboItemList.EndUpdate();");
            sb.AppendLine(AddTabs(6) + "}");
            sb.AppendLine(AddTabs(5) + "}");
            sb.AppendLine(AddTabs(4) + "}");
            sb.AppendLine(AddTabs(4) + "catch");
            sb.AppendLine(AddTabs(4) + "{");
            sb.AppendLine(AddTabs(5) + "return false;");
            sb.AppendLine(AddTabs(4) + "}");
            sb.AppendLine();
            sb.AppendLine(AddTabs(4) + "this.Cursor = Cursors.Default;");
            sb.AppendLine(AddTabs(4) + "return true;");
            sb.AppendLine(AddTabs(3) + "}");
            sb.AppendLine();

            sb.AppendLine(AddTabs(2) + "#endregion");
            sb.AppendLine();
            #endregion

            #region Events
            sb.AppendLine(AddTabs(2) + "#region Events");
            sb.AppendLine();

            sb.AppendLine(AddTabs(3) + "private void btnCancel_Click(object sender, EventArgs e)");
            sb.AppendLine(AddTabs(3) + "{");
            sb.AppendLine(AddTabs(3) + "}");
            sb.AppendLine(AddTabs(3) + "private void btnSave_Click(object sender, EventArgs e)");
            sb.AppendLine(AddTabs(3) + "{");
            sb.AppendLine(AddTabs(3) + "}");
            sb.AppendLine(AddTabs(3) + "private void cboItemList_SelectedIndexChanged(object sender, EventArgs e)");
            sb.AppendLine(AddTabs(3) + "{");
            sb.AppendLine(AddTabs(3) + "}");

            sb.AppendLine();
            sb.AppendLine(AddTabs(2) + "#endregion");
            #endregion

            sb.AppendLine(AddTabs(1) + "}");
            sb.AppendLine("}");

            output.Body = sb.ToString();
            return(output);
        }