Beispiel #1
0
 public void Update(Venue venue)
 {
     if(venue.HasPendingEdits) {
     throw new ApiException(
       "Cannot edit venue pending approval: " + venue.PartnerVenueId);
       }
       var updateResource = RESOURCE + venue.Id;
       Save(venue, updateResource, Method.PUT);
 }
Beispiel #2
0
 public void Create(Venue venue)
 {
     Save(venue, RESOURCE, Method.POST);
 }
Beispiel #3
0
        void Save(Venue venue, string saveResource, Method method)
        {
            var restRequest = GetRestRequest(venue, saveResource, method);

              try {
            var response = restClient.Execute(restRequest);
            if (response.StatusCode != HttpStatusCode.Created
                  && response.StatusCode != HttpStatusCode.OK) {
              throw new ApiException("Error saving venue: " + response.Content);
            }
              }
              catch (Exception ex) {
            throw new ApiException(ex.Message);
              }
        }
Beispiel #4
0
 public VenueRequest(Venue venue, string saveResource, Method method)
 {
     if(venue.HasPendingEdits && method != Method.POST) {
       throw new ApiException(
     "Cannot edit venue pending approval: " + venue.PartnerVenueId);
     }
     Venue = venue;
     Resource = saveResource;
     Method = method;
 }
Beispiel #5
0
        IRestRequest GetRestRequest(Venue venue, string getResource, Method method)
        {
            var restRequest = requestFactory.Create(getResource, method);
              restRequest.RequestFormat = DataFormat.Json;
              string data = restRequest.JsonSerializer.Serialize(venue.ToMessage());
              data = Encoding.ASCII.GetString(Encoding.UTF8.GetBytes(data));

              restRequest.AddParameter("application/json", data,
            ParameterType.RequestBody);
              restRequest.Timeout = 500;
              return restRequest;
        }