Ejemplo n.º 1
0
        public void Update(CMSPageUpdateRequest model,
            string userId)
        {
            DataProvider.ExecuteNonQuery(GetConnection, "dbo.CMSPage_UpdateById"
               , inputParamMapper: delegate(SqlParameterCollection paramCollection)
               {
                   //Make sure @names match exactly those in DB parameters
                   paramCollection.AddWithValue("@Name", model.Name);
                   paramCollection.AddWithValue("@Url", model.Url);
                   paramCollection.AddWithValue("@PubDate", model.PubDate);
                   paramCollection.AddWithValue("@ExpireDate", model.ExpireDate);
                   paramCollection.AddWithValue("@TemplateId", model.TemplateId);
                   paramCollection.AddWithValue("@Metatag", model.Metatag);
                   paramCollection.AddWithValue("@MetaDescription", model.MetaDescription);
                   paramCollection.AddWithValue("@UserId", userId);
                   paramCollection.AddWithValue("@Id", model.Id);
                   paramCollection.AddWithValue("@Active", model.Active);
                   paramCollection.AddWithValue("@IncludeInNavigation", model.IncludeInNavigation);

               });
        }
        public HttpResponseMessage UpdatePage(CMSPageUpdateRequest model, int CMSPageId)
        {
            // if the Model does not pass validation, there will be an Error response returned with errors
            if (!ModelState.IsValid)
            {
                return Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState);
            }

            string userId = _userService.GetCurrentUserId();
            //pass in userId to page method

            _cmsService.Update(model, userId);

            SuccessResponse response = new SuccessResponse();

            return Request.CreateResponse(HttpStatusCode.OK, response);
        }