// POST api/sme
        public HttpResponseMessage Insert(SMEAddRequest model)
        {
            if (!ModelState.IsValid)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState));
            }
            try
            {
                ItemResponse <int> resp = new ItemResponse <int>();
                resp.Item = _SMEService.Insert(model);

                return(Request.CreateResponse(HttpStatusCode.OK, resp));
            }
            catch (Exception ex)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex));
            }
        }
Beispiel #2
0
        public int Insert(SMEAddRequest model)
        {
            int Id = 0;

            DataProvider.ExecuteNonQuery(storedProc : "dbo.SME_Insert", inputParamMapper : delegate(SqlParameterCollection paramCollection)
            {
                paramCollection.AddWithValue("@ModBy", model.ModifiedBy);
                paramCollection.AddWithValue("@MaxInt", model.MaxInteractionsPer1k);
                paramCollection.AddWithValue("@MinInt", model.MinInteractionsPer1k);
                paramCollection.AddWithValue("@SumInt", model.SumInteractionsPer1k);

                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);
        }