Beispiel #1
0
        public ActionResult Details(int id)
        {
            List <Lactation> lactations = interfaceService.GetLactationCow(id);

            ViewBag.lastLactation = null;
            ViewBag.lastLactation = null;

            Lactation currentLactation = lactations.FirstOrDefault(l => l.finished == false);
            Lactation lastLactation    = null;

            if (currentLactation != null)
            {
                ViewBag.currentLactation = interfaceService.GetLactationEMA(currentLactation.idLactation);
            }

            if (lactations.Where(l => l.finished == true).Count() >= 1)
            {
                List <Lactation> lactationFinished = lactations.Where(l => l.finished == true).OrderBy(l => l.dateBirth).ToList();
                lastLactation         = lactationFinished[lactationFinished.Count - 1];
                ViewBag.lastLactation = interfaceService.GetLactationEMA(lastLactation.idLactation);
            }

            ViewBag.notifications = interfaceService.GetNotificationCow(id);
            ViewBag.foods         = interfaceService.GetAllFoodByCow(id).OrderByDescending(f => f.date).ToList();

            double forecastValue = interfaceService.GetPrediction(id);

            ViewBag.forecastValue = forecastValue;

            return(View(lactations));
        }
        public DTO_LactationDetails GetLactation(int id)
        {
            //Tratar referencia ciclica Loop
            Lactation lac = interfaceService.GetLactationById(id);

            DTO_LactationDetails dtoLac = new DTO_LactationDetails {
                idLactation = lac.idLactation,
                yields      = (from y in lac.yields
                               select new DTO_Yield
                {
                    date = y.date,
                    dayLactation = y.dayLactation,
                    totalYield = y.totalYield
                }).ToList(),
                yieldEMA = interfaceService.GetLactationEMA(id)
            };

            return(dtoLac);
        }