public HttpResponseMessage translate(AdditionalService 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 (AdditionalService.MasterPostExists(post.id) == false) { return(Request.CreateResponse <string>(HttpStatusCode.BadRequest, "The additional service does not exist")); } else if (ValueAddedTax.MasterPostExists(post.value_added_tax_id) == false) { return(Request.CreateResponse <string>(HttpStatusCode.BadRequest, "The value added tax does not exist")); } // Make sure that the data is valid post.product_code = AnnytabDataValidation.TruncateString(post.product_code, 50); post.name = AnnytabDataValidation.TruncateString(post.name, 100); post.fee = AnnytabDataValidation.TruncateDecimal(post.fee, 0, 9999999999.99M); post.account_code = AnnytabDataValidation.TruncateString(post.account_code, 10); // Get the saved post AdditionalService savedPost = AdditionalService.GetOneById(post.id, languageId); // Check if we should add or update the post if (savedPost == null) { AdditionalService.AddLanguagePost(post, languageId); } else { AdditionalService.UpdateLanguagePost(post, languageId); } // Return the success response return(Request.CreateResponse <string>(HttpStatusCode.OK, "The translation was successful")); } // End of the translate method