Пример #1
0
        public Int32 Add(PageMetaTagsAddRequest model, string userId)
        {
            Int32 id = 0;

            DataProvider.ExecuteNonQuery(GetConnection, "dbo.PageMetaTags_Insert"
               , inputParamMapper: delegate (SqlParameterCollection paramCollection)
               {
                   paramCollection.AddWithValue("@MetaTagId", model.MetaTagId);
                   paramCollection.AddWithValue("@Value", model.Value);
                   paramCollection.AddWithValue("@OwnerId", model.OwnerId);
                   paramCollection.AddWithValue("@OwnerType", model.OwnerType);
                   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;
        }
        public HttpResponseMessage AddPageMetaTag(PageMetaTagsAddRequest model)
        {
            if (!ModelState.IsValid)
            {
                return Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState);
            }

            string userId = _userService.GetCurrentUserId();
            ItemResponse<Int32> response = new ItemResponse<Int32>();

            response.Item = _metaTagsService.Add(model, userId);

            return Request.CreateResponse(response);
        }