public void FeedbackTest() { var repository = new FeedbackRepository(new MongoContext("mongodb://localhost/WeatherAggregator")); var listBefore = repository.GetAll(); repository.Add(new Feedback { DateCreated = DateTime.Now, Email = "lol.com", Name = "lol", Text = "Text" }); var listAfter = repository.GetAll(); Assert.Greater(listAfter.Count, listBefore.Count, "The item hasn't been added."); }
public async Task <IActionResult> GetAll() { var feedbacks = await feedbackRepository.GetAll(); return(Ok(new { Results = feedbacks })); }
public IHttpActionResult Get() { var feedbackFromDB = feedbackDB.GetAll(); if (feedbackFromDB.Count != 0) { return(Ok(feedbackFromDB)); } else { return(StatusCode(HttpStatusCode.NoContent)); } }
public FeedbackModule() { IFeedbackRepository repo = new FeedbackRepository(ConfigurationManager.ConnectionStrings["happyIndex"].ConnectionString); Get["/api/feedback/{id:Guid}"] = parameters => { return(repo.GetById(parameters.id)); }; Get["/api/feedback"] = _ => { var feedbackData = repo.GetAll(); var feedback = new List <Feedback>(); foreach (var f in feedbackData) { feedback.Add(new Feedback() { CreateDate = f.CreateDate, Id = f.Id, Indicator = f.Indicator, PollingStation = f.PollingStation, QuestionId = f.QuestionId, QuestionsShownIds = f.QuestionsShownIds }); } return(feedback); }; Post["/api/feedback"] = _ => { var feedback = this.Bind <Feedback>(); var newFeedback = repo.Add(feedback.Indicator, feedback.QuestionId, DateTime.UtcNow, feedback.PollingStation, feedback.QuestionsShownIds); return(newFeedback); }; Delete["/api/feedback/{id:Guid}"] = parameters => { return(repo.DeleteById(parameters.id)); }; }
public List <Feedback> GetAllFeedbacks() { return(feedRepo.GetAll()); }
public IHttpActionResult Get() { return(Ok(feedbackRepository.GetAll())); }
public static List <Feedback> GetAll() { return(FeedbackRepository.GetAll()); }
public async Task <IEnumerable <Feedback> > Get() { return(await repo.GetAll()); }