コード例 #1
0
        public int InsertRating(CompanyRatingInsertRequest model)
        {
            int id = 0;

            try
            {
                DataProvider.ExecuteNonQuery(GetConnection, "dbo.CompanyRating_Insert"
                                             , inputParamMapper : delegate(SqlParameterCollection paramCollection)
                {
                    paramCollection.AddWithValue("@companyId", model.CompanyId);
                    paramCollection.AddWithValue("@rating", model.Rating);
                    paramCollection.AddWithValue("@ratingComment", model.RatingComment);
                    paramCollection.AddWithValue("@raterId", model.RaterId);

                    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);
                });
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(id);
        }
コード例 #2
0
        public HttpResponseMessage InsertRating(CompanyRatingInsertRequest model)

        {
            if (!ModelState.IsValid)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState));
            }



            int ratingId = _CompanyRatingService.InsertRating(model);

            ItemResponse <int> response = new ItemResponse <int> {
                Item = ratingId
            };

            return(Request.CreateResponse(HttpStatusCode.OK, response));
        }