public JsonResult GetFutureAndPast() { DateTime present = DateTime.Now; DateTime EndDate = DateTime.Now.AddDays(5); var forecastCards = db.ForecastCards.Where(x => x.DateTime.Day != present.Day && x.DateTime >= present && x.DateTime <= EndDate) .ToList() .Select(card => new JsonCard(card)) .ToList(); EndDate = DateTime.Now.AddDays(-5); var historyCards = db.HistoryCards.Where(x => x.DateTime.Day != present.Day && x.DateTime <= present && x.DateTime > EndDate) .ToList() .Select(card => new JsonCard(card)) .ToList(); PackageFutureAndPast package = LogicGetFutureAndPast.CreateEachDayCards(forecastCards, historyCards); Response.AppendHeader("Access-Control-Allow-Origin", "*"); return(Json(package, JsonRequestBehavior.AllowGet)); }
public void CreateEachDayCards_CorrectData() { List <JsonCard> forecastCards = new List <JsonCard>(); List <JsonCard> historyCards = new List <JsonCard>(); historyCards.Add(new JsonCard() { Date = "14.11", Temperature = 13, Humidity = 80f, Description = "-", WindDirection = "WE" }); historyCards.Add(new JsonCard() { Date = "14.11", Temperature = 13, Humidity = 75, Description = "-", WindDirection = "E" }); historyCards.Add(new JsonCard() { Date = "14.11", Temperature = 14, Humidity = 73f, Description = "-", WindDirection = "E" }); historyCards.Add(new JsonCard() { Date = "14.11", Temperature = 15, Humidity = 75f, Description = "-", WindDirection = "NE" }); historyCards.Add(new JsonCard() { Date = "14.11", Temperature = 15, Humidity = 75f, Description = "-", WindDirection = "NE" }); historyCards.Add(new JsonCard() { Date = "14.11", Temperature = 14, Humidity = 70f, Description = "-", WindDirection = "NE" }); historyCards.Add(new JsonCard() { Date = "14.11", Temperature = 13, Humidity = 84.33f, Description = "-", WindDirection = "WE" }); historyCards.Add(new JsonCard() { Date = "14.11", Temperature = 13, Humidity = 84.33f, Description = "-", WindDirection = "WE" }); historyCards.Add(new JsonCard() { Date = "16.11", Temperature = 15, Humidity = 80f, Description = "-", WindDirection = "WE" }); historyCards.Add(new JsonCard() { Date = "16.11", Temperature = 14, Humidity = 75, Description = "-", WindDirection = "E" }); historyCards.Add(new JsonCard() { Date = "16.11", Temperature = 16, Humidity = 73f, Description = "-", WindDirection = "E" }); historyCards.Add(new JsonCard() { Date = "16.11", Temperature = 16, Humidity = 75f, Description = "-", WindDirection = "E" }); historyCards.Add(new JsonCard() { Date = "16.11", Temperature = 15, Humidity = 75f, Description = "-", WindDirection = "E" }); historyCards.Add(new JsonCard() { Date = "16.11", Temperature = 14, Humidity = 70f, Description = "-", WindDirection = "NE" }); historyCards.Add(new JsonCard() { Date = "16.11", Temperature = 13, Humidity = 84.33f, Description = "-", WindDirection = "WE" }); historyCards.Add(new JsonCard() { Date = "16.11", Temperature = 13, Humidity = 82f, Description = "-", WindDirection = "WE" }); PackageFutureAndPast package = new PackageFutureAndPast(); package.Future.Add(new JsonCard() { Date = "16.11", Temperature = 14, Humidity = 77.08f, Description = "-", WindDirection = "NE" }); package.Past.Add(new JsonCard() { Date = "14.11", Temperature = 13, Humidity = 76.79f, Description = "-", WindDirection = "E" }); PackageFutureAndPast packageFutureAndPast = LogicGetFutureAndPast.CreateEachDayCards(forecastCards, historyCards); CheckCountPackage(package, packageFutureAndPast); CheckPackageFutureAndPast(package, packageFutureAndPast); }