Ejemplo n.º 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);
 }
Ejemplo n.º 2
0
 public void Create(Venue venue)
 {
     Save(venue, RESOURCE, Method.POST);
 }
Ejemplo n.º 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);
              }
        }
Ejemplo n.º 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;
 }
Ejemplo n.º 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;
        }