public ActionResult Subscribe([System.Web.Http.FromBody] SubscribePayload data) { // TODO: move data validation if (!data.IsValid()) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest, "invalid data")); } try { facetService.Add(data.Token, FacetIDs.SubscriptionTokens); } catch (Exception ex) { Log.Error($"Error adding '${FacetIDs.SubscriptionTokens}' facet value", ex, this); return(new HttpStatusCodeResult(HttpStatusCode.InternalServerError, ex.Message)); } try { facetService.Add(data.EventId, FacetIDs.Subscriptions); sessionEventSubscriptionsService.Add(data.EventId); } catch (Exception ex) { Log.Error($"Error adding '${FacetIDs.Subscriptions}' facet value", ex, this); return(new HttpStatusCodeResult(HttpStatusCode.InternalServerError, ex.Message)); } return(new HttpStatusCodeResult(HttpStatusCode.OK)); }
public ActionResult Add([System.Web.Http.FromBody] EventPayload data) { // TODO: move data validation if (!data.IsValid()) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest, "invalid data")); } try { facetService.Add(data.EventIdFormatted, FacetIDs.RegisteredEvents); } catch (Exception ex) { Log.Error($"Unable to add value '{data.EventId}' to contact's '${FacetIDs.RegisteredEvents}' facet ", ex, this); return(new HttpStatusCodeResult(HttpStatusCode.InternalServerError, ex.Message)); } return(new HttpStatusCodeResult(HttpStatusCode.OK)); }