public HttpResponseMessage Add(AnalyticsAddRequest model)
        {
            if (!ModelState.IsValid)
            {
                return Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState);
            }

            string userId = _userService.GetCurrentUserId();

            ItemResponse<int> response = new ItemResponse<int>();

            response.Item = _analyticsService.Insert(model, userId);

            return Request.CreateResponse(response);
        }
        public int Insert(AnalyticsAddRequest model, string userId)
        {
            int Id = 0;

            DataProvider.ExecuteNonQuery(GetConnection, "dbo.Analytics_Insert"
               , inputParamMapper: delegate (SqlParameterCollection paramCollection)
               {
                   paramCollection.AddWithValue("@Category", model.Category);
                   paramCollection.AddWithValue("@Action", model.Action);
                   paramCollection.AddWithValue("@Value", model.Value);
                   paramCollection.AddWithValue("@Data", model.Data);
                   paramCollection.AddWithValue("@UserId", userId);
                   paramCollection.AddWithValue("@PageType", model.PageType);
                   paramCollection.AddWithValue("@PageUrl", model.PageUrl);

                   SqlParameter p = new SqlParameter("@Id", System.Data.SqlDbType.Int);
                   p.Direction = System.Data.ParameterDirection.Output;

                   paramCollection.Add(p);

               }, returnParameters: delegate (SqlParameterCollection param)
               {
                   int.TryParse(param["@Id"].Value.ToString(), out Id);
               }
               );

            return Id;
        }