public IHttpActionResult Get(int id) { var fb = feedbackRepository.Get(id); if (fb == null) { return(StatusCode(HttpStatusCode.NoContent)); } fb.Links.Add(new Link() { Url = "http://localhost:9799/api/adminlogin", Method = "GET", Relation = "Get All feedbacks" }); fb.Links.Add(new Link() { Url = "http://localhost:9799/api/adminlogin", Method = "Post", Relation = "Create New feedbacks" }); fb.Links.Add(new Link() { Url = HttpContext.Current.Request.Url.AbsoluteUri.ToString(), Method = "GET", Relation = "Self" }); fb.Links.Add(new Link() { Url = HttpContext.Current.Request.Url.AbsoluteUri.ToString(), Method = "Put", Relation = "Modify exsisting feedbacks" }); fb.Links.Add(new Link() { Url = HttpContext.Current.Request.Url.AbsoluteUri.ToString(), Method = "Delete", Relation = "Remove exsisting feedbacks" }); return(Ok(feedbackRepository.Get(id))); }
public IHttpActionResult Get(int id) { var feedbackFromDB = feedbackDB.Get(id); if (feedbackFromDB != null) { var result = feedbackFromDB.AddLinks( new HyperMedia { Href = Url.Link("GetFeedbacks", null), Method = "GET", Rel = "Get all feedbacks." }, new HyperMedia { Href = Url.Link("GetFeedbackByID", new { id = id }), Method = "GET", Rel = "Get one feedback by ID." }, new HyperMedia { Href = Url.Link("PostFeedback", new { id = id }), Method = "GET", Rel = "Post feedback." }, new HyperMedia { Href = Url.Link("GetFeedbackByCustomerID", new { id = id }), Method = "GET", Rel = "Post feedback." } ); return(Ok(result)); } else { return(StatusCode(HttpStatusCode.NoContent)); } }
public void GetFeedbacks_should_return_all_feedbacks() { // Act var results = Controller.GetFeedbacks().GetAwaiter().GetResult(); // Assert Assert.AreEqual(results.Value.Count, Repository.Get().GetAwaiter().GetResult().Count); }
public Feedback GetById(int id) { return(feedRepo.Get(id)); }