Guest User

Untitled

a guest
Jan 22nd, 2019
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.82 KB | None | 0 0
  1. $.ajax({
  2. url: "/api/GuestPartyAPI/" + cerid,
  3. type: "GETAD",
  4. async: false,
  5. data: { Id: id, Name: name, NeedsHotel: needshotel_bool, TableNo: tableno, QR_CodeImage: qrcodeimage,
  6. AddressLabel: addresslabel, Address_1: address1, Address_2: address2, City: city, State: state,
  7. PostalCode: postalcode, Country: country, Email: email, Phone: phone
  8. },
  9. dataType: "json"
  10. }).fail(function (jqXHR, textStatus) {
  11. console.log(jqXHR);
  12. console.log(textStatus);
  13. //alert("cerid " + cerid);
  14. //alert("Request failed: " + textStatus);
  15. });
  16.  
  17. [AcceptVerbs("GETAD")]
  18. public HttpResponseMessage GetGuestPartyCer(int cerid, GuestParty guestparty)
  19. {
  20.  
  21. if (ModelState.IsValid)
  22. {
  23. db.GuestParties.AddObject(guestparty);
  24. db.SaveChanges();
  25.  
  26. CeremonyGuestParty ceremonygp = new CeremonyGuestParty(); //create a CeremonyGuestParty entry to link ceremony and guestparty
  27. ceremonygp.CeremonyId = cerid;
  28. ceremonygp.GuestPartyId = guestparty.Id;
  29. db.CeremonyGuestParties.AddObject(ceremonygp);
  30. db.SaveChanges();
  31.  
  32. HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.Created, guestparty);
  33. response.Headers.Location = new Uri(Url.Link("DefaultApi", new { id = guestparty.Id }));
  34. return response;
  35. }
  36. else
  37. {
  38. return Request.CreateResponse(HttpStatusCode.BadRequest);
  39. }
  40. }
  41.  
  42. config.Routes.MapHttpRoute(
  43. name: "DefaultApi",
  44. routeTemplate: "api/{controller}/{id}",
  45. defaults: new { id = RouteParameter.Optional }
  46. );
  47.  
  48. public HttpResponseMessage GetGuestPartyCer(int id, GuestParty guestparty)
Add Comment
Please, Sign In to add comment