diff --git a/TrackerLibrary/DataAccess/SqlConnector.cs b/TrackerLibrary/DataAccess/SqlConnector.cs index 6700461..14a0123 100644 --- a/TrackerLibrary/DataAccess/SqlConnector.cs +++ b/TrackerLibrary/DataAccess/SqlConnector.cs @@ -1,7 +1,16 @@ -using System; +using Dapper; +using System; using System.Collections.Generic; +using System.Data; using System.Text; + +//@PlaceNumber int, +//@PlaceName nvarchar(50), +//@PrizeAmount money, +// @PrizePercentage float, +//@id int = 0 output + namespace TrackerLibrary.DataAccess { public class SqlConnector : IDataConnection @@ -14,8 +23,21 @@ namespace TrackerLibrary.DataAccess /// The prize information, including the unique identifier. public Models.PrizeModel CreatePrize(Models.PrizeModel model) { - model.Id = 1; - return model; + using (IDbConnection connection = new System.Data.SqlClient.SqlConnection(GlobalConfig.CnnString("Tournaments"))) + { + var p = new DynamicParameters(); + p.Add("@PlaceNumber", model.PlaceNumber); + p.Add("@PlaceName", model.PlaceName); + p.Add("@PrizeAmount", model.PrizeAmount); + p.Add("@PrizePercentage", model.PrizePercentage); + p.Add("@Id", 0, dbType: DbType.Int32, direction: ParameterDirection.Output); + + connection.Execute("dbo.spPrizes_Insert", p, commandType: CommandType.StoredProcedure); + + model.Id = p.Get("@Id"); + + return model; + } } } } diff --git a/TrackerLibrary/GlobalConfig.cs b/TrackerLibrary/GlobalConfig.cs index bbdaa2d..fc874a2 100644 --- a/TrackerLibrary/GlobalConfig.cs +++ b/TrackerLibrary/GlobalConfig.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Text; using TrackerLibrary.DataAccess; +using System.Configuration; namespace TrackerLibrary { @@ -23,6 +24,12 @@ namespace TrackerLibrary TextConnector text = new TextConnector(); Connections.Add(text); } + + } + + public static string CnnString(string name) + { + return ConfigurationManager.ConnectionStrings[name].ConnectionString; } } } diff --git a/TrackerLibrary/Properties/AssemblyInfo.cs b/TrackerLibrary/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..ed577f9 --- /dev/null +++ b/TrackerLibrary/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("TrackerLibrary")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("TrackerLibrary")] +[assembly: AssemblyCopyright("Copyright © 2020")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("27ba8b4b-4ef6-4ca2-8e43-7c930552ecd9")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/TrackerLibrary/TrackerLibrary.csproj b/TrackerLibrary/TrackerLibrary.csproj index 9f5c4f4..fe0dfd3 100644 --- a/TrackerLibrary/TrackerLibrary.csproj +++ b/TrackerLibrary/TrackerLibrary.csproj @@ -1,7 +1,64 @@ - - + + + - netstandard2.0 + Debug + AnyCPU + {27BA8B4B-4EF6-4CA2-8E43-7C930552ECD9} + Library + Properties + TrackerLibrary + TrackerLibrary + v4.7.2 + 512 + true - - + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + ..\packages\Dapper.2.0.30\lib\net461\Dapper.dll + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/TrackerLibrary/packages.config b/TrackerLibrary/packages.config new file mode 100644 index 0000000..e38523d --- /dev/null +++ b/TrackerLibrary/packages.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/TrackerUI/App.config b/TrackerUI/App.config index 56efbc7..8683d13 100644 --- a/TrackerUI/App.config +++ b/TrackerUI/App.config @@ -1,5 +1,8 @@  + + + diff --git a/TrackerUI/CreatePrizeForm.cs b/TrackerUI/CreatePrizeForm.cs index e71e834..e5b7312 100644 --- a/TrackerUI/CreatePrizeForm.cs +++ b/TrackerUI/CreatePrizeForm.cs @@ -71,7 +71,7 @@ namespace TrackerUI int prizePercentage = 0; bool prizeAmountValid = decimal.TryParse(prizeAmountValue.Text, out prizeAmount); - bool prizePercentageValid = int.TryParse(prizeAmountValue.Text, out prizePercentage); + bool prizePercentageValid = int.TryParse(prizePercentageValue.Text, out prizePercentage); if (prizePercentageValid == false || prizeAmountValid == false) { diff --git a/TrackerUI/TrackerUI.csproj b/TrackerUI/TrackerUI.csproj index cedd801..2615348 100644 --- a/TrackerUI/TrackerUI.csproj +++ b/TrackerUI/TrackerUI.csproj @@ -117,7 +117,7 @@ - {b4ffd708-5d53-4d58-b5a6-5691020ef6dc} + {27ba8b4b-4ef6-4ca2-8e43-7c930552ecd9} TrackerLibrary