Esempio n. 1
0
        public HttpResponseMessage update_template(CustomThemeTemplate post)
        {
            // Check for errors
            if (post == null)
            {
                return(Request.CreateResponse <string>(HttpStatusCode.BadRequest, "The post is null"));
            }

            // Make sure that the data is valid
            post.user_file_name  = AnnytabDataValidation.TruncateString(post.user_file_name, 200);
            post.master_file_url = AnnytabDataValidation.TruncateString(post.master_file_url, 100);
            post.comment         = AnnytabDataValidation.TruncateString(post.comment, 200);

            // Get the saved post
            CustomThemeTemplate savedPost = CustomThemeTemplate.GetOneById(post.custom_theme_id, post.user_file_name);

            // Check if the post exists
            if (savedPost == null)
            {
                return(Request.CreateResponse <string>(HttpStatusCode.BadRequest, "The record does not exist"));
            }

            // Update the post
            CustomTheme.UpdateTemplate(post);

            // Return the success response
            return(Request.CreateResponse <string>(HttpStatusCode.OK, "The update was successful"));
        } // End of the update_template method
Esempio n. 2
0
        public CustomThemeTemplate get_template_by_id(Int32 id = 0, string userFileName = "")
        {
            // Create the post to return
            CustomThemeTemplate post = CustomThemeTemplate.GetOneById(id, userFileName);

            // Return the post
            return(post);
        } // End of the get_template_by_id method