using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Components.Web;
using Microsoft.AspNetCore.Components;
using System.Diagnostics;
using System.Globalization;
using Microsoft.AspNetCore.Components.Server.ProtectedBrowserStorage;
using Microsoft.JSInterop;
using System.IO;
using System.Net;
using System.Net.Sockets;
using System.Text;
using System.Net.Http;
using System.Data.SqlClient;
using System.Data;
using Todo.Pages;
namespace Todo.Pages
{
    public partial class Register
    {
    [Inject]
    IJSRuntime JSRuntime { get; set; }
    public string register_name{get;set;}="";
    public string register_lastname{get;set;}="";
    public string register_email{get;set;}="";
    public string register_password{get;set;}="";
    public void registergiris(){
            string db = @"workstation id=blazortodos.mssql.somee.com;packet size=4096;user id=latral4_SQLLogin_1;pwd=516swqticy;data source=blazortodos.mssql.somee.com;persist security info=False;initial catalog=blazortodos";    
            SqlConnection baglanti = new SqlConnection(db);
            SqlCommand cmd = baglanti.CreateCommand();
            cmd.CommandText ="exec user_register '"+register_name+"','"+register_lastname+"','"+register_email+"','"+register_password+"',@result OUTPUT"; 
                SqlParameter outputParam = cmd.Parameters.Add("@result", SqlDbType.Int);
                outputParam.Direction = ParameterDirection.Output;
                
                if(register_name == "" || register_lastname == "" || register_email == "" || register_password == "")
                {
                JSRuntime.InvokeVoidAsync("JSRegCallback3");
                }
                else{
                baglanti.Open();
                cmd.ExecuteNonQuery();
    	               
                if(outputParam.Value.ToString()=="1")
				{
                JSRuntime.InvokeVoidAsync("JSRegCallback2");
                }
				else if(outputParam.Value.ToString()=="2")
				{
                JSRuntime.InvokeVoidAsync("JSRegCallback");
				}
                baglanti.Close();
                Console.WriteLine(outputParam.Value.ToString());
                }
        }
    }
}