public string Post([FromBody] CstInfo cstInfo)
 {
     return(AdminDBConnection.CstCreateAcct(cstInfo));
 }
        public static string CstCreateAcct(CstInfo newLoginDetails)
        {
            Code    = PasswordCreation.GenerateCode();
            Hashpwd = HashPassword.ComputeSha256Hash(Code);

            DateTime current = DateTime.Now;

            SqlCommand cmd    = new SqlCommand();
            SqlCommand cmdAct = new SqlCommand();


            try
            {
                if (newLoginDetails.CstFName == "" || newLoginDetails.CstLName == "")
                {
                    throw new Exception();
                }

                if (newLoginDetails.CstEmail == "")
                {
                    throw new Exception();
                }

                if (!newLoginDetails.CstEmail.Contains("@gmail.com"))
                {
                    throw new Exception();
                }
                cmd.Parameters.Clear();
                cmd.Connection  = con;
                cmd.CommandText = @"INSERT INTO NewCstTable(cst_FirstName, cst_LastName, cst_Email, cst_Password, Created_acct_at) OUTPUT INSERTED.id_cst VALUES(@fname, @lname, @email, @token, @timestamp)";

                cmd.Parameters.AddWithValue("@fname", newLoginDetails.CstFName);
                cmd.Parameters.AddWithValue("@lname", newLoginDetails.CstLName);
                cmd.Parameters.AddWithValue("@email", newLoginDetails.CstEmail);
                cmd.Parameters.AddWithValue("@token", Hashpwd);
                cmd.Parameters.AddWithValue("@timestamp", current);
                con.Open();
                cstId = Convert.ToInt32(cmd.ExecuteScalar());//cmd.ExecuteNonQuery();
                con.Close();

                cmdAct.Parameters.Clear();
                cmdAct.Connection  = con;
                cmdAct.CommandText = string.Format("insert into AccountTable  values(@acttype, @cstid, @actnum, @bal)");
                cmdAct.Parameters.AddWithValue("@acttype", newLoginDetails.CstAcctType);
                cmdAct.Parameters.AddWithValue("@cstid", cstId);
                cmdAct.Parameters.AddWithValue("@actnum", PasswordCreation.GenerateAccount());
                cmdAct.Parameters.AddWithValue("@bal", Convert.ToDouble(newLoginDetails.Balance));

                con.Open();
                cmdAct.ExecuteNonQuery();

                try
                {
                    MailMessage mail       = new MailMessage();
                    SmtpClient  SmtpServer = new SmtpClient("smtp.gmail.com");
                    mail.From = new MailAddress("*****@*****.**");
                    mail.To.Add(newLoginDetails.CstEmail);
                    mail.Subject           = "Cst Info";
                    mail.Body              = $"Your Access code: {Code} \nUse your email {newLoginDetails.CstEmail} and access code to login";
                    SmtpServer.Port        = 587;
                    SmtpServer.Credentials = new System.Net.NetworkCredential("*****@*****.**", Pwd);
                    SmtpServer.EnableSsl   = true;

                    SmtpServer.Send(mail);
                }
                catch (Exception ex)
                {
                    return($"CstFailed from inner catch msg sending why => {ex.Message}");
                }

                return($"Customer sucessfull Signup => {cstId}");
            }
            catch (Exception ex)
            {
                return($"CStFailed from catch why => {ex.Message}");
            }
            finally
            {
                con.Close();
            }
        }