public ActionResult MilkProductionList() { MilkproductionList milklist = new MilkproductionList(); var types = AnimalInformationDBAcces.GetEnabledAnimalType(); if (types != null) { milklist.VAnimalTypes = types.Select(x => new SelectListItem { Value = x.PKAnimalTypeId.ToString(), Text = x.AnimalTypeName }); } var animallist = AnimalInformationDBAcces.GetEnabledFemaleAnimal(); if (animallist != null) { milklist.Manimallist = animallist.Select(x => new SelectListItem { Value = x.PKAnimalId.ToString(), Text = x.AnimalCodeName }); } milklist.DateMax = System.DateTime.UtcNow.AddHours(6).Date; milklist.DateMin = milklist.DateMax.AddDays(-30); var milkproductionlist = AnimalInformationDBAcces.GetMilkProductionList(milklist.DateMin, milklist.DateMax); milklist.milkProductions = milkproductionlist; return(View(milklist)); }
public ActionResult MilkProductionList(MilkproductionList milklist) { var types = AnimalInformationDBAcces.GetEnabledAnimalType(); if (types != null) { milklist.VAnimalTypes = types.Select(x => new SelectListItem { Value = x.PKAnimalTypeId.ToString(), Text = x.AnimalTypeName }); } var animallist = AnimalInformationDBAcces.GetEnabledFemaleAnimal(); if (animallist != null) { milklist.Manimallist = animallist.Select(x => new SelectListItem { Value = x.PKAnimalId.ToString(), Text = x.AnimalCodeName }); } var milkproductionlist = AnimalInformationDBAcces.GetMilkProductionList(milklist.DateMin, milklist.DateMax); if (milklist.VAnimalTypeId != null) { milkproductionlist = milkproductionlist.Where(a => a.animal.AnimalTypeId == milklist.VAnimalTypeId).ToList(); } if (milklist.MAnimalId != null) { milkproductionlist = milkproductionlist.Where(a => a.AnimalId == milklist.MAnimalId).ToList(); } if (milklist.MorningAmountMin != null) { milkproductionlist = milkproductionlist.Where(a => a.MorningAmount >= milklist.MorningAmountMin).ToList(); } if (milklist.MorningAmountMax != null) { milkproductionlist = milkproductionlist.Where(a => a.MorningAmount <= milklist.MorningAmountMax).ToList(); } if (milklist.AfternoonAmountMin != null) { milkproductionlist = milkproductionlist.Where(a => a.AfternoonAmount >= milklist.AfternoonAmountMin).ToList(); } if (milklist.AfternoonAmountMax != null) { milkproductionlist = milkproductionlist.Where(a => a.AfternoonAmount <= milklist.AfternoonAmountMax).ToList(); } milklist.milkProductions = milkproductionlist; return(View(milklist)); }