public int Insert(FaqCategoryAddRequest model) { //SqlParameter idOut = new SqlParameter("@Id", 0); //idOut.Direction = System.Data.ParameterDirection.Output; int id = 0; Adapter.ExecuteQuery("dbo.FaqCategory_Insert", new[] { SqlDbParameter.Instance.BuildParameter("@Title", model.Title, System.Data.SqlDbType.NVarChar, 200), SqlDbParameter.Instance.BuildParameter("@Description", model.Description, System.Data.SqlDbType.NVarChar, 4000), 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); }
public HttpResponseMessage Post(FaqCategoryAddRequest model) { try { int id = _faqCategoryService.Insert(model); return(Request.CreateResponse(HttpStatusCode.OK, id)); } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex.Message)); } }
public HttpResponseMessage Insert(FaqCategoryAddRequest model) { try { ItemResponse <int> response = new ItemResponse <int>(); response.Item = _faqCategoryService.Insert(model); return(Request.CreateResponse(HttpStatusCode.OK, response)); } catch (Exception ex) { _errorService.LogError(ex); return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex)); } }
public int Insert(FaqCategoryAddRequest model) { int Id = 0; DataProvider.ExecuteNonQuery("dbo.FaqCategory_Insert" , inputParamMapper : delegate(SqlParameterCollection paramCollection) { paramCollection.AddWithValue("@DisplayName", model.DisplayName); paramCollection.AddWithValue("@Description", model.Description); paramCollection.AddWithValue("@ModifiedBy", model.ModifiedBy); 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); }