public HttpResponseMessage AddTemplate(CMSTemplateAddRequest 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); } string userId = _userService.GetCurrentUserId(); ItemResponse<int> response = new ItemResponse<int>(); //pass in userId to page method response.Item = _cmsService.AddTemplate(model); return Request.CreateResponse(response); }
// // //Kayla's Code // // public int AddTemplate(CMSTemplateAddRequest template) { int id = 0; DataProvider.ExecuteNonQuery(GetConnection, "dbo.CMSTemplates_Insert" , inputParamMapper: delegate (SqlParameterCollection paramCollection) { paramCollection.AddWithValue("@Name", template.Name); paramCollection.AddWithValue("@Path", template.Path); 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; }