コード例 #1
0
 public HttpResponseMessage Insert(HelpAddRequest model)
 {
     if (!ModelState.IsValid)
     {
         return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState));
     }
     try
     {
         ItemResponse <int> resp = new ItemResponse <int>();
         resp.Item = _helpService.Insert(model);
         return(Request.CreateResponse(HttpStatusCode.OK, resp));
     }
     catch (Exception ex)
     {
         return(Request.CreateResponse(HttpStatusCode.BadRequest, ex));
     }
 }
コード例 #2
0
        public int Insert(HelpAddRequest model)
        {
            int Id = 0;

            DataProvider.ExecuteNonQuery("dbo.Help_Insert"
                                         , inputParamMapper : delegate(SqlParameterCollection paramCollection)
            {
                paramCollection.AddWithValue("@DispName", model.DispName);
                paramCollection.AddWithValue("@HelpCategoryId", model.HelpCategoryId);
                paramCollection.AddWithValue("@Title", model.Title);
                paramCollection.AddWithValue("@HelpMsg", model.HelpMsg);
                paramCollection.AddWithValue("@ModifiedBy", model.ModifiedBy);

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

                paramCollection.Add(idParameter);
            }
                                         , returnParameters : delegate(SqlParameterCollection param)
            {
                Int32.TryParse(param["@Id"].Value.ToString(), out Id);
            });
            return(Id);
        }