示例#1
0
        public int Insert(PrivacyPolicyAddRequest model) 
        {
            int id = 0; 

            DataProvider.ExecuteNonQuery(GetConnection, "dbo.PrivacyPolicy_Insert" 
               , inputParamMapper: delegate (SqlParameterCollection paramCollection)
               {
                   paramCollection.AddWithValue("@ParentId", model.ParentId);
                   paramCollection.AddWithValue("@Title", model.Title);
                   paramCollection.AddWithValue("@Description", model.Description);
                   paramCollection.AddWithValue("@DisplayOrder", model.DisplayOrder);
                   paramCollection.AddWithValue("@CreatedBy", model.CreatedBy);   

                   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;
        }
示例#2
0
        public int Add(PrivacyPolicyAddRequest data, int userId)
        {
            if (data == null)
            {
                throw new ArgumentNullException("Parameter data is required");
            }
            int id = 0;

            string storeProc = "[dbo].[PrivacyPolicy_Insert]";

            _dataProvider.ExecuteNonQuery(storeProc,
                                          delegate(SqlParameterCollection sqlParams)

            {
                sqlParams.AddWithValue("@Title", data.Title);
                sqlParams.AddWithValue("@Paragraph", data.Paragraph);
                sqlParams.AddWithValue("@UserId", userId);
                sqlParams.AddWithValue("@SortOrder", data.SortOrder);



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

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

            return(id);
        }
示例#3
0
 public IHttpActionResult Post(PrivacyPolicyAddRequest model)
 {
     try
     {
         if (!ModelState.IsValid)
         {
             return(BadRequest(ModelState));
         }
         ItemResponse <int> response = new ItemResponse <int>
         {
             Item = _privacyPolicyService.Insert(model)
         };
         return(Ok(response));
     }
     catch (Exception ex)
     {
         return(BadRequest(ex.Message));
     }
 }
示例#4
0
        public int Insert(PrivacyPolicyAddRequest model)
        {
            int returnValue = 0;

            DataProvider.ExecuteNonQuery("dbo.PrivacyPolicy_Insert",
                                         inputParamMapper: (SqlParameterCollection inputs) =>
            {
                inputs.AddWithValue("@Heading", model.Heading);
                inputs.AddWithValue("@Body", model.Body);
                inputs.AddWithValue("@DisplayOrder", model.DisplayOrder);
                SqlParameter idOut = new SqlParameter("@Id", 0);
                idOut.Direction    = ParameterDirection.Output;
                inputs.Add(idOut);
            },
                                         returnParameters: (SqlParameterCollection inputs) =>
            {
                int.TryParse(inputs["@Id"].Value.ToString(), out returnValue);
            });
            return(returnValue);
        }