public ViewResult ConsumptionReportHerdDay(DateTime day) { List<ConsumptionReportHerd> report = new List<ConsumptionReportHerd>(); Herd aux = new Herd(); Milker aux1 = new Milker(); Cow aux2 = new Cow(); List<Cow> cows = new List<Cow>(); Production production = new Production(); var Herd = from h in db.Herds.ToList() select h; var Milker = from o in db.Milkers.ToList() select o; //var Cow = from c in a.Cows.ToList() select c; foreach (Herd h in Herd) { ConsumptionReportHerd item = new ConsumptionReportHerd(); Double hay = new Double(); Double Silage = new Double(); item.IdHerd = h.Id; item.NameHerd = h.Name; item.HowCows = h.Cows.Count(); foreach (Milker o in Milker) { aux1.Name = o.Name; } item.NameOpe = aux1.Name; cows = h.Cows; foreach (Cow c in cows) { var query = from co in db.Consumptions.ToList() where co.Id == c.Id && co.Date == day && c.State.Equals('A') select co; foreach (Consumption co in query) { hay = hay + co.HayAmount; Silage = Silage + co.SilageAmout; } item.HayAmount = hay; item.SilageAmout = Silage; } report.Add(item); } return View(report); }
public ViewResult ConsumptionReportCowMonth(DateTime Month) { List<ConsumptionReportCow> report = new List<ConsumptionReportCow>(); Cow aux = new Cow(); Production production = new Production(); var cows = from c in db.Cows.ToList() select c; //var Consumption = from co in a.Consumptions.ToList() select co; foreach (Cow c in cows) { ConsumptionReportCow item = new ConsumptionReportCow(); Double Hay = new Double(); Double Silage = new Double(); item.IdCow = c.Id; item.NameCow = c.Name; //var resultPro = Consumption.Where(p => p.CowId.Equals(c.Id)); var query = from co in db.Consumptions.ToList() where co.Id == c.Id && co.Date.Month.Equals(Month.Month) && co.Date.Month.Equals(Month.Year) && c.State.Equals('A') select co; foreach (Consumption co in query) { Hay = Hay + co.HayAmount; Silage = Silage + co.SilageAmout; } item.HayAmount = Hay; item.SilageAmout = Silage; report.Add(item); } return View(report); }
public ViewResult ProductionReportHerdMonth(DateTime Month) { List<ProductionReportHerd> report = new List<ProductionReportHerd>(); Herd aux = new Herd(); Milker aux1 = new Milker(); Cow aux2 = new Cow(); List<Cow> cows = new List<Cow>(); Production production = new Production(); var Herd = from h in db.Herds.ToList() select h; var Milker = from o in db.Milkers.ToList() select o; //var Cow = from c in a.Cows.ToList() select c; foreach (Herd h in Herd) { ProductionReportHerd item = new ProductionReportHerd(); Double quant = new Double(); item.IdHerd = h.Id; item.NameHerd = h.Name; foreach (Milker o in Milker) { aux1.Name = o.Name; } item.NameOpe = aux1.Name; cows = h.Cows; foreach (Cow c in cows) { var query = from co in db.Productions.ToList() where co.Id == c.Id && c.State.Equals('A') && co.Date.Month.Equals(Month.Month) && co.Date.Year.Equals(Month.Year) && c.State.Equals('A') select co; foreach (Production p in query) { quant = quant + p.Quant; } quant = quant / (query.ToList<Production>().Count); } report.Add(item); } return View(report); }
public ViewResult ProductionReportCowMonth(string month, string year) { DateTime Month = new DateTime(Int32.Parse(year), Int32.Parse(month), 1); List<ProductionReportCow> report = new List<ProductionReportCow>(); Cow aux = new Cow(); Production production = new Production(); var cows = from c in db.Cows.ToList() select c; var cowsq = from c in cows.ToList() where c.State == "A" select c; foreach (Cow c in cowsq) { ProductionReportCow item = new ProductionReportCow(); Double sum = new Double(); item.IdCow = c.Id; item.NameCow = c.Name; // var resultPro = productions.Where(p => p.CowId.Equals(c.Id)); var query = from p in db.Productions where p.CowId == c.Id && p.Date.Month == Month.Month && p.Date.Year == Month.Year select p; foreach (Production p in query) sum += p.Quant; item.Quant = sum; report.Add(item); } return View(report); }
public ActionResult Edit(Cow cow) { if (ModelState.IsValid) { db.Entry(cow).State = EntityState.Modified; db.SaveChanges(); return RedirectToAction("Index"); } ViewBag.MotherId = new SelectList(db.Cows, "Id", "Name", cow.MotherId); ViewBag.HerdId = new SelectList(db.Herds, "Id", "Name", cow.HerdId); return View(cow); }
public ActionResult Create(Cow cow) { cow.State = "A"; if (ModelState.IsValid) { db.Cows.Add(cow); db.SaveChanges(); return RedirectToAction("Index"); } ViewBag.MotherId = new SelectList(db.Cows, "Id", "Name", cow.MotherId); ViewBag.HerdId = new SelectList(db.Herds, "Id", "Name", cow.HerdId); return View(cow); }