public ActionResult Insert(AnimalView model) { var m = batch.GetAllBatches().Find(x => x.BatchTypeid == model.BatchTypeid); int count = ani.GetAllAnimals().FindAll(x => x.BatchTypeDesc.Contains(model.AniCode.Substring(0, 2))).Count; ViewBag.Batchtypeid = new SelectList(_db2.GetAllBatchTypes(), "BatchTypeid", "BatchTypeDesc"); if (ani.tot(model)==0) { if(count<m.NumOfAnimals) { ani.InsertAnimals(model); count = count = ani.GetAllAnimals().FindAll(x => x.BatchTypeDesc.Contains(model.AniCode.Substring(0, 2))).Count; if (count < m.NumOfAnimals) { return RedirectToAction("InsertAnimals"); } } } else { ViewBag.Exist = "The current cost you have entered must be less than total cost"; return View(model); } return RedirectToAction("GetAllAnimals"); }
public void AnimalDetails(AnimalView model) { using (var animal = new AnimalRepository()) { Animal ani = animal.GetById(model.AnimalId); } }
public string GenerateAnimalId(AnimalView model) { string id = ""; foreach (var b in bat.GetAll()) { if (b.BatchTypeid == model.BatchTypeid) { id = (b.BatchTypeDesc.Substring(0,2) + "-" + "SU" + "-" + 0 + "-" + "-" + Guid.NewGuid().ToString().Substring(0, 5)).ToUpper(); } } return id; }
public decimal current(AnimalView view) { decimal current = 0; var animal = new AnimalRepository(); foreach (var model in batches.GetAll()) { if (view.BatchTypeid == model.BatchTypeid) { current = (model.Totalcost / model.NumOfAnimals); } } return current; }
public ActionResult InsertAnimals(AnimalView model) { ViewBag.Batchtypeid = new SelectList(_db2.GetAllBatchTypes(), "BatchTypeid", "BatchTypeDesc"); return View(ani.GetAnimalById2(model)); }
public List<Animalpar> GetAllAnimals() { decimal sum = 0; AnimalView model = new AnimalView(); using (var b = new AnimalRepository()) { return b.GetAll().Select(x => new Animalpar { AnimalId = x.AnimalId, AniCode = x.AniCode, BatchTypeDesc = bat.GetAll().Find(y => y.BatchTypeid == x.BatchTypeid).BatchTypeDesc, AniColor = x.AniColor, AniFeedingStatus = "FeedLot", AniAge = x.AniAge, AniGender = x.AniGender, AniHealthStatus = "Healthy", AniCurrentCost = x.AniCurrentCost, AniSaleStatus = "Not Ready", AniTotCost = 0, AnimalValue = Convert.ToDouble(x.AniCurrentCost + x.AniTotCost), }).ToList(); } }
public int TotalCost(AnimalView model) { decimal sum = 0; sum = GetAllAnimals().FindAll(x => x.AniCode.Substring(0,2) == model.AniCode.Substring(0,2)).Sum(x => x.AniCurrentCost) + model.AniCurrentCost; var m = batches.GetAll().Find(x => x.BatchTypeid == model.BatchTypeid); if (sum > m.Totalcost || sum < m.Totalcost) { num = 1; } else { num = 0; } return num; }
public void InsertAnimals(AnimalView model) { using (var x = new AnimalRepository()) { var animals = new Animal { AnimalId = model.AnimalId, AniCode = model.AniCode, BatchTypeid = model.BatchTypeid, AniColor = model.AniColor, AniFeedingStatus = "FeedLot", AniAge = model.AniAge, AniGender = model.AniGender, AniHealthStatus = "Healthy", AniCurrentCost = model.AniCurrentCost, AniSaleStatus = "Not Ready", AniTotCost = 0, AnimalValue = model.AnimalValue, }; x.Insert(animals); } }
public AnimalView GetAnimalById2(AnimalView anView) { decimal sum = 0; int count = 0; count++; sum = anima.GetAll().Sum(x => x.AniCurrentCost); using (var animal = new AnimalRepository()) { foreach (var c in bat.GetAll()) { Batch ani = batches.GetAll().FindLast(x => x.BatchTypeid == c.BatchTypeid); if (ani != null) { anView.AnimalId = count; anView.AniCode = ani.BatchCode+ "-" + "SU" + "-" + anView.AnimalId + "-" + Guid.NewGuid().ToString().Substring(0, 5); anView.BatchTypeid = anView.BatchTypeid; anView.AniColor = ""; anView.AniFeedingStatus = "Feeding Lot"; anView.AniAge = 0; anView.AniGender = ""; anView.AniHealthStatus = "Healthy"; anView.AniCurrentCost = ani.Totalcost / ani.NumOfAnimals; anView.AniSaleStatus = "Not Ready"; anView.AniTotCost = 0; anView.AnimalValue = Convert.ToDouble(anView.AniCurrentCost + anView.AniTotCost); } } return anView; } }