public HttpResponseMessage AddPlanFeature(PlanFeatureAddRequest model)
        {
            if (!ModelState.IsValid)
            {
                return Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState);
            }
            string userId = _userService.GetCurrentUserId();

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

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

            return Request.CreateResponse(response);
        }
Ejemplo n.º 2
0
        public int Insert(PlanFeatureAddRequest model, string userId)
        {
            int id = 0;

            DataProvider.ExecuteNonQuery(GetConnection, "dbo.PlanFeatures_Insert"
               , inputParamMapper: delegate (SqlParameterCollection paramCollection)
               {
                   paramCollection.AddWithValue("@Title", model.Title);
                   paramCollection.AddWithValue("@Description", model.Description);
                   paramCollection.AddWithValue("@Category", model.Category);
                   paramCollection.AddWithValue("@SortOrder", model.SortOrder);
                   paramCollection.AddWithValue("@PlanId", model.PlanId);
                   paramCollection.AddWithValue("@UserId", userId);

                   SqlParameter p = new SqlParameter("@Id", System.Data.SqlDbType.Int);
                   p.Direction = System.Data.ParameterDirection.Output;

                   paramCollection.Add(p);

               }, returnParameters: delegate (SqlParameterCollection param)
               {
                   Int32.TryParse(param["@id"].Value.ToString(), out id);
               }
               );

            return id;
        }