Ejemplo n.º 1
0
        public IHttpActionResult RequestToBeHost([FromBody] HostRequestDto hostRequest)
        {
            return(Authorized(token =>
            {
                try
                {
                    _finderService.RequestToBeHost(token, hostRequest);

                    // Call Analytics
                    var props = new EventProperties {
                        { "City", hostRequest.Address.City }, { "State", hostRequest.Address.State }, { "Zip", hostRequest.Address.PostalCode }
                    };
                    _analyticsService.Track(hostRequest.ContactId.ToString(), "RegisteredAsHost", props);

                    return Ok();
                }
                catch (GatheringException e)
                {
                    _logger.Error("Host already has a gathering at this location.", e);
                    throw new HttpResponseException(HttpStatusCode.NotAcceptable);
                }
                catch (Exception e)
                {
                    _logger.Error("Could not generate request", e);
                    throw new HttpResponseException(new ApiErrorDto("Gathering request failed", e).HttpResponseMessage);
                }
            }));
        }