/// <summary> /// Updates a real estate project. /// </summary> /// <param name="realEstateProject">The <see cref="IS24RestApi.Offer.RealEstateProject.RealEstateProject" /> object.</param> /// <returns> /// The task object representing the asynchronous operation. /// </returns> /// <exception cref="IS24Exception"></exception> public async Task UpdateAsync(RealEstateProject realEstateProject) { var req = Connection.CreateRequest("realestateproject/{id}", Method.PUT); req.AddParameter("id", realEstateProject.Id.Value, ParameterType.UrlSegment); req.AddBody(realEstateProject); var resp = await ExecuteAsync<Messages>(Connection, req); if (!resp.IsSuccessful()) { throw new IS24Exception(string.Format("Error updating real estate project {0}: {1}", realEstateProject.Id, resp.ToMessage())) { Messages = resp }; } }
public async Task RealEstateProject_Update_RequestsCorrectResource() { Http.RespondWith(m => { Assert.Equal("PUT", m); Assert.Equal("http://rest.sandbox-immobilienscout24.de/restapi/api/offer/v1.0/user/me/realestateproject/4711", Http.Url.ToString()); return new Messages { Message = { new Message { MessageCode = MessageCode.MESSAGE_RESOURCE_UPDATED, MessageProperty = "" } } }; }); var project = new RealEstateProject { Id = 4711 }; await Client.RealEstateProjects.UpdateAsync(project); }
public async Task RealEstateProject_Update_PostsRealEstateObject() { Http.RespondWith(m => { var c = new BaseXmlDeserializer().Deserialize<RealEstateProject>(new RestResponse { Content = Http.RequestBody }); Assert.IsType<RealEstateProject>(c); Assert.Equal(4711, c.Id); return new Messages { Message = { new Message { MessageCode = MessageCode.MESSAGE_RESOURCE_UPDATED, MessageProperty = "" } } }; }); var project = new RealEstateProject { Id = 4711 }; await Client.RealEstateProjects.UpdateAsync(project); }