public int Insert(FaqItemAddRequest model) { //SqlParameter idOut = new SqlParameter("@Id", 0); //idOut.Direction = System.Data.ParameterDirection.Output; int id = 0; Adapter.ExecuteQuery("dbo.FaqItem_Insert", new[] { SqlDbParameter.Instance.BuildParameter("@FaqCategoryId", model.FaqCategoryId, System.Data.SqlDbType.Int), SqlDbParameter.Instance.BuildParameter("@Question", model.Question, System.Data.SqlDbType.NVarChar, 200), SqlDbParameter.Instance.BuildParameter("@Answer", model.Answer, System.Data.SqlDbType.NVarChar, 4000), SqlDbParameter.Instance.BuildParameter("@DisplayOrder", model.DisplayOrder, System.Data.SqlDbType.Int), SqlDbParameter.Instance.BuildParameter("@IsActive", model.IsActive, System.Data.SqlDbType.Bit), 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(FaqItemAddRequest model) { try { int id = _faqItemService.Insert(model); return(Request.CreateResponse(HttpStatusCode.OK, id)); } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex.Message)); } }