using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Villain.Data.Types;
using Villain.Databases;

namespace Fiesta.Databases.World.StoredProcedures
{
	public class p_Char_Create
	{
		Int32 CharNo;

		public p_Char_Create(Int32 userNo, byte createWorld, byte adminLevel, byte slotNo, string id, byte race, byte pClass, byte gender, byte hairType, byte hairColor, byte faceShape)
		{
			SQLServer sqlServer = DatabaseManager.Get<SQLServer>("World");

			id = id.Truncate(20);

			SqlCommand command = sqlServer.StoredProcedure(
				"p_Char_Create",
				new SqlParameter[]
				{
					new SqlParameter("@nUserNo", userNo),
					new SqlParameter("@nCreateWorld", createWorld),
					new SqlParameter("@nAdminLevel", adminLevel),
					new SqlParameter("@nSlotNo", slotNo),
					new SqlParameter("@sID", id),
					new SqlParameter("@nRace", race),
					new SqlParameter("@nClass", pClass),
					new SqlParameter("@nGender", gender),
					new SqlParameter("@nHairType", hairType),
					new SqlParameter("@nHairColor", hairColor),
					new SqlParameter("@nFaceShape", faceShape),

					new SqlParameter("@nCharNo", SqlDbType.Int){
						Direction = ParameterDirection.Output
					}
				}
			);

			command.ExecuteNonQuery();

			command.TryParse("@nCharNo", out CharNo);
		}
	}
}