using System; using System.Collections.Generic; using System.Linq; using System.ServiceModel; using System.ServiceModel.Activation; using System.ServiceModel.Web; using System.Text; using MyFriendsAround.Common.Entities; using MyFriendsAround.Data.BLL; namespace MyFriendsAround.WcfREST { // Start the service and browse to http://:/Service1/help to view the service's generated help page // NOTE: By default, a new instance of the service is created for each call; change the InstanceContextMode to Single if you want // a single instance of the service to process all calls. [ServiceContract] [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)] [ServiceBehavior(InstanceContextMode = InstanceContextMode.PerCall)] // NOTE: If the service is renamed, remember to update the global.asax.cs file public class Service1 { // TODO: Implement the collection resource that will contain the SampleItem instances [WebGet(UriTemplate = "")] public List GetCollection() { // TODO: Replace the current implementation to return a collection of SampleItem instances return new List() { new SampleItem() { Id = 1, StringValue = "Hello" } }; } [WebInvoke(UriTemplate = "", Method = "POST")] public SampleItem Create(SampleItem instance) { // TODO: Add the new instance of SampleItem to the collection throw new NotImplementedException(); } [WebGet(UriTemplate = "{id}")] public SampleItem Get(string id) { // TODO: Return the instance of SampleItem with the given id throw new NotImplementedException(); } [WebInvoke(UriTemplate = "{id}", Method = "PUT")] public SampleItem Update(string id, SampleItem instance) { // TODO: Update the given instance of SampleItem in the collection throw new NotImplementedException(); } [WebInvoke(UriTemplate = "{id}", Method = "DELETE")] public void Delete(string id) { // TODO: Remove the instance of SampleItem with the given id from the collection throw new NotImplementedException(); } [WebGet(UriTemplate = "GetFriends", ResponseFormat = WebMessageFormat.Json)] public List GetFriends() { List list = FriendsRepository.GetFriends(); return list; } [OperationContract] [WebInvoke] public bool PublishLocation(Friend friend) { return FriendsRepository.PublishLocation(friend); } } }