Exemplo n.º 1
0
        public HttpResponseMessage Insert(FAQsAddRequest model)
        {
            if (!ModelState.IsValid)
            {
                return(Request.CreateResponse(HttpStatusCode.BadRequest, ModelState));
            }

            ItemResponse <int> response = new ItemResponse <int>();

            string userId = _userService.GetCurrentUserId();

            response.Item = _faqsService.Insert(model, userId);

            return(Request.CreateResponse(HttpStatusCode.OK, response));
        }
Exemplo n.º 2
0
    public int Insert(FAQsAddRequest model, string userId)
    {
        int id = 0;

        DataProvider.ExecuteNonQuery(GetConnection, "dbo.FAQs_Insert"
                                     , inputParamMapper : delegate(SqlParameterCollection paramCollection)
        {
            SqlParameter ids = new SqlParameter("@CatList", System.Data.SqlDbType.Structured);

            if (model.Categories != null && model.Categories.Any())
            {
                ids.Value = new object.Data.IntIdTable(model.Categories);
            }

            paramCollection.Add(ids);



            paramCollection.AddWithValue("@Question", model.Question);;
            paramCollection.AddWithValue("@DisplayOrder", model.DisplayOrder);
            paramCollection.AddWithValue("@CreatedDate", model.CreatedDate);
            paramCollection.AddWithValue("@CreatedBy", userId);
            paramCollection.AddWithValue("@ModifiedDate", model.ModifiedDate);
            paramCollection.AddWithValue("@Answer", model.Answer);

            SqlParameter p = new SqlParameter("@Id", System.Data.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);
    }