public HttpResponseMessage Create(CMSTemplateCreateRequest req)
        {
            if (req == null)
            {
                ModelState.AddModelError("", "You did not add any body data");
            }
            if (!ModelState.IsValid)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState));
            }
            int id = cmsService.Create(req);
            ItemResponse <int> itemResponse = new ItemResponse <int>();

            itemResponse.Item = id;
            return(Request.CreateResponse(HttpStatusCode.OK, itemResponse));
        }
예제 #2
0
        public int Create(CMSTemplateCreateRequest req)
        {
            int newId = 0;

            dataProvider.ExecuteNonQuery(
                "CMSTemplates_Create",
                inputParamMapper: (parameters) =>
            {
                parameters.AddWithValue("@Name", req.Name);
                parameters.AddWithValue("@TemplateHtml", req.TemplateHtml);
                parameters.Add("@Id", SqlDbType.Int).Direction = ParameterDirection.Output;
            },
                returnParameters: (parameters) =>
            {
                newId = (int)parameters["@Id"].Value;
            });
            return(newId);
        }