public HttpResponseMessage update(ProductOptionType post) { // Check for errors if (post == null) { return(Request.CreateResponse <string>(HttpStatusCode.BadRequest, "The post is null")); } else if (Product.MasterPostExists(post.product_id) == false) { return(Request.CreateResponse <string>(HttpStatusCode.BadRequest, "The product does not exist")); } else if (OptionType.MasterPostExists(post.option_type_id) == false) { return(Request.CreateResponse <string>(HttpStatusCode.BadRequest, "The option type does not exist")); } // Get the saved post ProductOptionType savedPost = ProductOptionType.GetOneById(post.id); // Check if the post exists if (savedPost == null) { return(Request.CreateResponse <string>(HttpStatusCode.BadRequest, "The record does not exist")); } // Update the post ProductOptionType.Update(post); // Return the success response return(Request.CreateResponse <string>(HttpStatusCode.OK, "The update was successful")); } // End of the update method
public HttpResponseMessage add(Option post, Int32 languageId = 0) { // Check for errors if (post == null) { return(Request.CreateResponse <string>(HttpStatusCode.BadRequest, "The post is null")); } else if (Language.MasterPostExists(languageId) == false) { return(Request.CreateResponse <string>(HttpStatusCode.BadRequest, "The language does not exist")); } else if (OptionType.MasterPostExists(post.option_type_id) == false) { return(Request.CreateResponse <string>(HttpStatusCode.BadRequest, "The option type does not exist")); } // Make sure that the data is valid post.title = AnnytabDataValidation.TruncateString(post.title, 50); post.product_code_suffix = AnnytabDataValidation.TruncateString(post.product_code_suffix, 10); // Add the post Int64 insertId = Option.AddMasterPost(post); post.id = Convert.ToInt32(insertId); Option.AddLanguagePost(post, languageId); // Return the success response return(Request.CreateResponse <string>(HttpStatusCode.OK, "The post has been added")); } // End of the add method
public HttpResponseMessage add(ProductOptionType post) { // Check for errors if (post == null) { return(Request.CreateResponse <string>(HttpStatusCode.BadRequest, "The post is null")); } else if (Product.MasterPostExists(post.product_id) == false) { return(Request.CreateResponse <string>(HttpStatusCode.BadRequest, "The product does not exist")); } else if (OptionType.MasterPostExists(post.option_type_id) == false) { return(Request.CreateResponse <string>(HttpStatusCode.BadRequest, "The option type does not exist")); } // Add the post ProductOptionType.Add(post); // Return the success response return(Request.CreateResponse <string>(HttpStatusCode.OK, "The post has been added")); } // End of the add method
public HttpResponseMessage translate(OptionType post, Int32 languageId = 0) { // Check for errors if (post == null) { return(Request.CreateResponse <string>(HttpStatusCode.BadRequest, "The post is null")); } else if (Language.MasterPostExists(languageId) == false) { return(Request.CreateResponse <string>(HttpStatusCode.BadRequest, "The language does not exist")); } else if (OptionType.MasterPostExists(post.id) == false) { return(Request.CreateResponse <string>(HttpStatusCode.BadRequest, "The option type does not exist")); } // Make sure that the data is valid post.title = AnnytabDataValidation.TruncateString(post.title, 100); post.google_name = AnnytabDataValidation.TruncateString(post.google_name, 50); // Get the post OptionType savedPost = OptionType.GetOneById(post.id, languageId); // Check if we should add or update the post if (savedPost == null) { OptionType.AddLanguagePost(post, languageId); } else { OptionType.UpdateLanguagePost(post, languageId); } // Return the success response return(Request.CreateResponse <string>(HttpStatusCode.OK, "The translate was successful")); } // End of the translate method
public HttpResponseMessage update(Option post, Int32 languageId = 0) { // Check for errors if (post == null) { return(Request.CreateResponse <string>(HttpStatusCode.BadRequest, "The post is null")); } else if (Language.MasterPostExists(languageId) == false) { return(Request.CreateResponse <string>(HttpStatusCode.BadRequest, "The language does not exist")); } else if (OptionType.MasterPostExists(post.option_type_id) == false) { return(Request.CreateResponse <string>(HttpStatusCode.BadRequest, "The option type does not exist")); } // Make sure that the data is valid post.title = AnnytabDataValidation.TruncateString(post.title, 50); post.product_code_suffix = AnnytabDataValidation.TruncateString(post.product_code_suffix, 10); // Get the saved post Option savedPost = Option.GetOneById(post.id, languageId); // Check if the post exists if (savedPost == null) { return(Request.CreateResponse <string>(HttpStatusCode.BadRequest, "The record does not exist")); } // Update the post Option.UpdateMasterPost(post); Option.UpdateLanguagePost(post, languageId); // Return the success response return(Request.CreateResponse <string>(HttpStatusCode.OK, "The update was successful")); } // End of the update method