/// <summary> /// Allows the REST API to create or update a gift card /// </summary> /// <param name="parameters">Parameters passed in the URL of the REST API call. No parameters are expected at this time.</param> /// <param name="querystring">Name/value pairs from the REST API call querystring. This is not used in this method.</param> /// <param name="postdata">Serialized (JSON) version of the GiftCardDTO object</param> /// <returns>GiftCardDTO - Serialized (JSON) version of the gift card</returns> public override string PostAction(string parameters, NameValueCollection querystring, string postdata) { var errors = new List <ApiError>(); GiftCardDTO postedCard = null; try { postedCard = Json.ObjectFromJson <GiftCardDTO>(postdata); } catch (Exception ex) { return(JsonApiResponseException(ex)); } var giftCard = new GiftCard(); giftCard.FromDto(postedCard); var existing = HccApp.CatalogServices.GiftCards.Find(giftCard.GiftCardId); if (existing == null) { HccApp.CatalogServices.GiftCards.Create(giftCard); } else { HccApp.CatalogServices.GiftCards.Update(giftCard); } return(JsonApiResponse(giftCard.ToDto())); }