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 MilkEdit(int TypeID) { List <MilkProduction> prevmilkproductionlist = AnimalInformationDBAcces.GetallMilkProductionByDate(System.DateTime.Now.Date);; prevmilkproductionlist = prevmilkproductionlist.Where(a => a.animal.AnimalTypeId == TypeID).ToList(); MilkProductionView tem = new MilkProductionView(); tem.ProductionDate = System.DateTime.Now.Date; List <MilkProductionPerCow> productionList = new List <MilkProductionPerCow>(); if (prevmilkproductionlist.Count != 0) { foreach (var animal in prevmilkproductionlist) { productionList.Add(new MilkProductionPerCow { AnimalID = animal.AnimalId, AnimalCode = animal.animal.AnimalCodeName, AfternoonAmount = animal.AfternoonAmount, MorningAmount = animal.MorningAmount }); } } tem.Cows = productionList; tem.AnimalTypeId = TypeID; return(View(tem)); }
public ActionResult Milk(int TypeID) { List <MilkProduction> prevmilkproductionlist = AnimalInformationDBAcces.GetallMilkProductionByDate(System.DateTime.Now.Date);; prevmilkproductionlist = prevmilkproductionlist.Where(a => a.animal.AnimalTypeId == TypeID).ToList(); List <AnimalInformation> animallist = new List <AnimalInformation>(); animallist = AnimalInformationDBAcces.GetEnabledFemaleAnimalByTypeId(TypeID); MilkProductionView tem = new MilkProductionView(); tem.ProductionDate = System.DateTime.Now.Date; List <MilkProductionPerCow> productionList = new List <MilkProductionPerCow>(); foreach (var animal in animallist) { var previnfo = prevmilkproductionlist.Where(a => a.AnimalId == animal.PKAnimalId).SingleOrDefault(); if (previnfo != null) { productionList.Add(new MilkProductionPerCow { AnimalID = animal.PKAnimalId, AnimalCode = animal.AnimalCodeName, AfternoonAmount = previnfo.AfternoonAmount, MorningAmount = previnfo.MorningAmount }); } else { productionList.Add(new MilkProductionPerCow { AnimalID = animal.PKAnimalId, AnimalCode = animal.AnimalCodeName, AfternoonAmount = 0, MorningAmount = 0 }); } } tem.Cows = productionList; tem.AnimalTypeId = TypeID; return(View(tem)); }
public ActionResult Add(AnimalType animalType) { if (ModelState.IsValid) { if (AnimalInformationDBAcces.IsAnimalTypeNameExists(animalType.AnimalTypeName)) { ModelState.AddModelError("AnimalTypeName", "Animal Type name already exist!!!"); return(View()); } else { AnimalType newAnimalType = new AnimalType(); newAnimalType.AnimalTypeName = animalType.AnimalTypeName; newAnimalType.IsDeleted = false; if (AnimalInformationDBAcces.AddAnimalType(newAnimalType)) { ViewBag.success = "Animal Type added successfully"; AnimalType tem = new AnimalType(); ModelState.Clear(); return(View(tem)); } else { ViewBag.success = "Unable to add please try again later!!!"; return(View()); } } } return(View()); }
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)); }
public ActionResult MilkEdit(MilkProductionView newentry, string Submit) { string name = HttpContext.User.Identity.Name; string operatorName = AgroExpressDBAccess.GetFullNamebyUserID(name); if (Submit == "Add") { if (ModelState.IsValid) { List <MilkProductionPerCow> tem = newentry.Cows; List <MilkProduction> entryList = new List <MilkProduction>(); var totalmilk = 0.0; foreach (var entry in tem) { if (entry.MorningAmount != 0 && entry.AfternoonAmount != 0) { entryList.Add(new MilkProduction { AnimalId = entry.AnimalID, Date = newentry.ProductionDate, AfternoonAmount = entry.AfternoonAmount, MorningAmount = entry.MorningAmount, OperatorName = operatorName }); totalmilk += entry.AfternoonAmount + entry.MorningAmount; } } if (totalmilk != 0) { if (AnimalInformationDBAcces.AddOrUpdateMilkProduction(entryList)) { if (AgroExpressDBAccess.AddOrUpdateTotalMilkSummary(newentry.ProductionDate, totalmilk)) { ViewBag.success = "Update Successful"; return(View(newentry)); } } } else { ViewBag.success = "Update Failed, Total Value Can not be Zero"; return(View(newentry)); } } return(View(newentry)); } else { ModelState.Clear(); List <MilkProduction> prevmilkproductionlist = AnimalInformationDBAcces.GetallMilkProductionByDate(newentry.ProductionDate);; prevmilkproductionlist = prevmilkproductionlist.Where(a => a.animal.AnimalTypeId == newentry.AnimalTypeId).ToList(); MilkProductionView tem = new MilkProductionView(); tem.ProductionDate = newentry.ProductionDate; List <MilkProductionPerCow> productionList = new List <MilkProductionPerCow>(); if (prevmilkproductionlist.Count != 0) { foreach (var animal in prevmilkproductionlist) { productionList.Add(new MilkProductionPerCow { AnimalID = animal.AnimalId, AnimalCode = animal.animal.AnimalCodeName, AfternoonAmount = animal.AfternoonAmount, MorningAmount = animal.MorningAmount }); } } tem.Cows = productionList; tem.AnimalTypeId = newentry.AnimalTypeId; return(View(tem)); } }
public ActionResult AnimalTypeListEdit() { var v = AnimalInformationDBAcces.GetEnabledAnimalType(); return(View(v)); }
public ActionResult Enable(int Id) { var v = AnimalInformationDBAcces.EnableAnimalType(Id); return(RedirectToAction("DisabledAnimalTypeList")); }
public ActionResult Delete(int Id) { var v = AnimalInformationDBAcces.DisableAnimalType(Id); return(RedirectToAction("List")); }