public HttpResponseMessage AddContent(CMSContentItemAddRequest model) { // if the Model does not pass validation, there will be an Error response returned with errors if (!ModelState.IsValid) { return Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState); } ItemResponse<int> response = new ItemResponse<int>(); response.Item = _cmsService.AddContent(model); return Request.CreateResponse(response); }
public int AddContent(CMSContentItemAddRequest model) { int id = 0; DataProvider.ExecuteNonQuery(GetConnection, "dbo.CMSContent_InsertContent" , inputParamMapper: delegate(SqlParameterCollection paramCollection) { paramCollection.AddWithValue("@CMSPageId", model.PageId); paramCollection.AddWithValue("@Value", model.Value); paramCollection.AddWithValue("@TemplateKeyId", model.TemplateKeyId); SqlParameter p = new SqlParameter("@Id", 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; }