コード例 #1
0
        public int Insert(AboutPageAddRequest model)
        {
            //SqlParameter idOut = new SqlParameter("@Id", 0);
            //idOut.Direction = System.Data.ParameterDirection.Output;
            int id = 0;

            Adapter.ExecuteQuery("dbo.AboutPage_Insert",
                                 new[]
            {
                SqlDbParameter.Instance.BuildParameter("@HeadLine", model.HeadLine, System.Data.SqlDbType.NVarChar, 50),
                SqlDbParameter.Instance.BuildParameter("@ContentText", model.ContentText, System.Data.SqlDbType.NVarChar, 500),
                SqlDbParameter.Instance.BuildParameter("@ImageURL", model.ImageURL, System.Data.SqlDbType.NVarChar, 255),
                SqlDbParameter.Instance.BuildParameter("@Id", 0, System.Data.SqlDbType.Int, paramDirection: System.Data.ParameterDirection.Output)

                //new SqlParameter("@Title", model.Title), THIS COULD BE IT BUT TOP ONE IS COOLER
                //new SqlParameter("@Message", model.Message),
                //new SqlParameter("@StackTrace", model.StackTrace),
                //new SqlParameter("@ErrorSourceTypeId", model.ErrorSourceTypeId),
            },
                                 (parameters =>
            {
                id = parameters.GetParamValue <int>("@Id");//an extention against the IDBparameters array
                //int.TryParse(parameters[4].Value.ToString(), out id);
            }
                                 ));
            return(id);
        }
コード例 #2
0
        public HttpResponseMessage Post(AboutPageAddRequest model)
        {
            try
            {
                int id = _aboutPageService.Insert(model);
                return(Request.CreateResponse(HttpStatusCode.OK, id));
            }

            catch (Exception ex)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex.Message));
            }
        }