public HttpResponseMessage update(OrderGiftCard 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 (GiftCard.MasterPostExists(post.gift_card_id) == false) { return(Request.CreateResponse <string>(HttpStatusCode.BadRequest, "The gift card does not exist")); } // Make sure that the data is valid post.gift_card_id = AnnytabDataValidation.TruncateString(post.gift_card_id, 50); post.amount = AnnytabDataValidation.TruncateDecimal(post.amount, 0, 999999999999M); // Get the saved post OrderGiftCard savedPost = OrderGiftCard.GetOneById(post.order_id, post.gift_card_id); // Check if the post exists if (savedPost == null) { return(Request.CreateResponse <string>(HttpStatusCode.BadRequest, "The record does not exist")); } // Update the post OrderGiftCard.Update(post); // Return the success response return(Request.CreateResponse <string>(HttpStatusCode.OK, "The update was successful")); } // End of the update method
public OrderGiftCard get_by_id(Int32 id = 0, string giftCardId = "") { // Create the post to return OrderGiftCard post = OrderGiftCard.GetOneById(id, giftCardId); // Return the post return(post); } // End of the get_by_id method