public OrderRow get_by_id(Int32 id = 0, string productCode = "") { // Create the post to return OrderRow post = OrderRow.GetOneById(id, productCode); // Return the post return(post); } // End of the get_by_id method
public HttpResponseMessage update(OrderRow post) { // Check for errors if (post == null) { return(Request.CreateResponse <string>(HttpStatusCode.BadRequest, "The post is null")); } else if (Order.MasterPostExists(post.order_id) == false) { return(Request.CreateResponse <string>(HttpStatusCode.BadRequest, "The order does not exist")); } else if (Unit.MasterPostExists(post.unit_id) == false) { return(Request.CreateResponse <string>(HttpStatusCode.BadRequest, "The unit does not exist")); } // Make sure that the data is valid post.product_code = AnnytabDataValidation.TruncateString(post.product_code, 50); post.manufacturer_code = AnnytabDataValidation.TruncateString(post.manufacturer_code, 50); post.gtin = AnnytabDataValidation.TruncateString(post.gtin, 20); post.product_name = AnnytabDataValidation.TruncateString(post.product_name, 100); post.vat_percent = AnnytabDataValidation.TruncateDecimal(post.vat_percent, 0, 9.99999M); post.quantity = AnnytabDataValidation.TruncateDecimal(post.quantity, 0, 999999.99M); post.unit_price = AnnytabDataValidation.TruncateDecimal(post.unit_price, 0, 9999999999.99M); post.account_code = AnnytabDataValidation.TruncateString(post.account_code, 10); post.supplier_erp_id = AnnytabDataValidation.TruncateString(post.supplier_erp_id, 20); // Get the saved post OrderRow savedPost = OrderRow.GetOneById(post.order_id, post.product_code); // Check if the post exists if (savedPost == null) { return(Request.CreateResponse <string>(HttpStatusCode.BadRequest, "The record does not exist")); } // Update the post OrderRow.Update(post); // Return the success response return(Request.CreateResponse <string>(HttpStatusCode.OK, "The update was successful")); } // End of the update method