Exemple #1
0
        /// <summary>
        /// Saves a record to the BusinessAreas table.
        /// </summary>
        public void Save(BowlingEntity bowlingEntity)
        {
            if (bowlingEntity == null)
            {
                throw new Exception(bowlingEntity + " not be null");
            }

            SqlParameter[] parameters = new SqlParameter[]
            {
                new SqlParameter("@Name", bowlingEntity.Name),
                new SqlParameter("@Score", bowlingEntity.Score),
                new SqlParameter("@ScoreDetails", bowlingEntity.ScoreDetails),
            };
            using (var con = new SqlConnection(this.connectionString))
            {
                con.Open();

                var cmd = new SqlCommand(" insert into [Score] ( "
                                         + "[Name],[Score], [ScoreDetails])"
                                         + " values ( @Name, @Score, @ScoreDetails)"
                                         + "select scope_identity()", con);
                cmd.Parameters.AddRange(parameters);
                cmd.ExecuteNonQuery();
                con.Close();
            }
        }
Exemple #2
0
 // POST api/bowling
 public void Post([FromBody] BowlingEntity bowlingEntity)
 {
     bowlingModel.Save(bowlingEntity);
 }