static async Task TestApi(IIdea test) { using (var client = new HttpClient()) { client.BaseAddress = new Uri("http://localhost:9000/"); client.DefaultRequestHeaders.Accept.Clear(); client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); // HTTP GET HttpResponseMessage response = await client.GetAsync("api/IIdeas/1"); if (response.IsSuccessStatusCode) { //IIdea idea = await response.Content.ReadAsAsync<idea>(); string s = await response.Content.ReadAsStringAsync(); //Console.WriteLine("{0}\t${1}\t{2}", idea.Name, idea.Price, idea.Category); } // HTTP POST //var i = new IIdea() { Name = "Gizmo", Price = 100, Category = "Widget" }; //response = await client.PostAsync("api/ideas", test); if (response.IsSuccessStatusCode) { Uri gizmoUrl = response.Headers.Location; // HTTP PUT test.Title = "test"; // Update price //response = await client.PutAsJsonAsync(gizmoUrl, test); // HTTP DELETE // response = await client.DeleteAsync(gizmoUrl); } } }
/// <summary> /// Constructor. /// </summary> /// <param name="idea">An <see cref="IIdea"/>.</param> /// <param name="ideaComment">An <see cref="IComment"/> for the paired Idea.</param> public IdeaIdeaCommentPair(IIdea idea, IComment ideaComment) { idea.ThrowOnNull("idea"); ideaComment.ThrowOnNull("ideaComment"); Idea = idea; IdeaComment = ideaComment; }
/// <summary> /// Constructor. /// </summary> /// <param name="idea">An <see cref="IIdea"/>.</param> /// <param name="ideaVote">An <see cref="IIdeaVote"/> for the paired Idea.</param> public IdeaIdeaVotePair(IIdea idea, IIdeaVote ideaVote) { idea.ThrowOnNull("idea"); ideaVote.ThrowOnNull("ideaVote"); Idea = idea; IdeaVote = ideaVote; }
public static string AuthorUrl(this UrlHelper urlHelper, IIdea idea) { try { return(idea == null || idea.AuthorId == null ? _defaultAuthorUrl : urlHelper.RouteUrl("PublicProfileIdeas", new { contactId = idea.AuthorId.Value })); } catch { return(_defaultAuthorUrl); } }
public IdeasController(IIdea repository, IMapper mapper) { _repository = repository; _mapper = mapper; }
/// <summary> /// Constructor. /// </summary> /// <param name="idea">The idea to get and set data for.</param> /// <param name="portalName">The configured name of the portal to get and set data for.</param> public IdeaDataAdapter(IIdea idea, string portalName = null) : this(idea.Entity, portalName) { }
/// <summary> /// Constructor. /// </summary> /// <param name="idea">The idea to get and set data for.</param> /// <param name="dependencies">The dependencies to use for getting and setting data.</param> public IdeaDataAdapter(IIdea idea, IDataAdapterDependencies dependencies) : this(idea.Entity, dependencies) { }
public IdeaController(IIdea ideaService) { _ideaService = ideaService; }