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

            string userId = _userService.GetCurrentUserId();

            ItemResponse<int> response = new ItemResponse<int>();
            response.Item = _referralService.Insert(model, userId);

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

            DataProvider.ExecuteNonQuery(GetConnection, "dbo.PartnerReferral_Insert",
                inputParamMapper: delegate(SqlParameterCollection paramCollection)
            {
                paramCollection.AddWithValue("@UserId", userId);
                paramCollection.AddWithValue("@PartnerType", model.PartnerType);
                paramCollection.AddWithValue("@PartnerName", model.PartnerName);
                paramCollection.AddWithValue("@Description", model.Description);
                paramCollection.AddWithValue("@URL", model.URL.ToString());
                paramCollection.AddWithValue("@AffiliateCode", model.AffiliateCode);

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

                paramCollection.Add(r);

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

            return referralId;
        }