public void DeleteFeedScheme(FeedingSchemeView model) { using (var feedSchemeRepo = new FeedingSchemeRepository()) { FeedingScheme feed = feedSchemeRepo.GetById(model.FeedingSchemeId); if (feed != null) { feedSchemeRepo.Delete(feed); } } }
public void DeleteFeedScheme(FeedingSchemeView model) { using (var feedSchemeRepo = new FeedingSchemeRepository()) { FeedingScheme feed = feedSchemeRepo.GetById(model.FeedingSchemeId); if (feed != null) { feedSchemeRepo.Delete(feed); } } }
public List <FeedingSchemePartialView> GetAllFeedSchemeViews() { using (var feedSchemeRepo = new FeedingSchemeRepository()) { var percBl = new PercentageBl(); return(feedSchemeRepo.GetAll().Select(x => new FeedingSchemePartialView { FeedingSchemeId = x.FeedingSchemeId, BatchTypeDesc = _bTypeRepo.GetAll().Find(j => j.BatchTypeid == x.BatchTypeid).BatchTypeDesc, NoOfAnimals = x.NoOfAnimals, DatePrepared = x.DatePrepared, NumIngredients = percBl.GetAllIngredients().Count(j => j.SchemeCode == x.SchemeCode), SchemeCode = x.SchemeCode, CostPerAnimal = x.TotalFeedingCost / x.NoOfAnimals, TotalCostForScheme = x.TotalFeedingCost// CalcTotalCost(x) }).ToList()); } }
public List<FeedingSchemePartialView> GetAllFeedSchemeViews() { using (var feedSchemeRepo = new FeedingSchemeRepository()) { var percBl = new PercentageBl(); return feedSchemeRepo.GetAll().Select(x => new FeedingSchemePartialView { FeedingSchemeId = x.FeedingSchemeId, BatchTypeDesc = _bTypeRepo.GetAll().Find(j=>j.BatchTypeid==x.BatchTypeid).BatchTypeDesc, NoOfAnimals = x.NoOfAnimals, DatePrepared = x.DatePrepared, NumIngredients = percBl.GetAllIngredients().Count(j => j.SchemeCode == x.SchemeCode), SchemeCode = x.SchemeCode, CostPerAnimal = x.TotalFeedingCost/x.NoOfAnimals, TotalCostForScheme = x.TotalFeedingCost// CalcTotalCost(x) }).ToList(); } }
public void UpdateFeedScheme(FeedingSchemePartialView model) { using (var feedSchemeRepo = new FeedingSchemeRepository()) { FeedingScheme feed = feedSchemeRepo.GetById(model.FeedingSchemeId); if (feed != null) { feed.FeedingSchemeId = model.FeedingSchemeId; feed.NoOfAnimals = model.NoOfAnimals; feed.DatePrepared = model.DatePrepared; feed.NumberOfItems = model.NumIngredients; feed.SchemeCode = model.SchemeCode; feed.FeedCostPerAnimal = model.CostPerAnimal; feed.TotalFeedingCost = model.TotalCostForScheme; feedSchemeRepo.Update(feed); } } }
public void AddFeedScheme(FeedingSchemeView model) { var datePre = DateTime.Today; Random rand = new Random(); using (var feedSchemeRepo = new FeedingSchemeRepository()) { var feed = new FeedingScheme() { FeedingSchemeId = model.FeedingSchemeId, BatchTypeid = _bTypeRepo.GetAll().ToList().Find(x => x.BatchTypeid == model.BatchTypeid).BatchTypeid, NoOfAnimals = CalcAniFeeding(model), DatePrepared = datePre, SchemeCode = datePre.DayOfYear + "#SC#" + CalcAniFeeding(model) + "#" + rand.Next(1, 1000000), FeedCostPerAnimal = 0, TotalFeedingCost = 0, NumberOfItems = 0 }; feedSchemeRepo.Insert(feed); } }
public void AddFeedScheme(FeedingSchemeView model) { var datePre = DateTime.Today; Random rand = new Random(); using (var feedSchemeRepo = new FeedingSchemeRepository()) { var feed = new FeedingScheme() { FeedingSchemeId = model.FeedingSchemeId, BatchTypeid = _bTypeRepo.GetAll().ToList().Find(x => x.BatchTypeid == model.BatchTypeid).BatchTypeid, NoOfAnimals = CalcAniFeeding(model), DatePrepared = datePre, SchemeCode = datePre.DayOfYear +"#SC#"+ CalcAniFeeding(model)+"#"+rand.Next(1,1000000), FeedCostPerAnimal = 0, TotalFeedingCost = 0, NumberOfItems = 0 }; feedSchemeRepo.Insert(feed); } }
public FeedingSchemePartialView GetFeedSchemeById(int id) { using (var feedSchemeRepo = new FeedingSchemeRepository()) { FeedingScheme feed = feedSchemeRepo.GetById(id); var feedView = new FeedingSchemePartialView(); if (feed != null) { feedView.FeedingSchemeId = feed.FeedingSchemeId; feedView.BatchTypeDesc = _bTypeRepo.GetAll().Find(j => j.BatchTypeid == feed.BatchTypeid).BatchTypeDesc; feedView.NoOfAnimals = feed.NoOfAnimals; feedView.DatePrepared = feed.DatePrepared; feedView.CostPerAnimal = feed.FeedCostPerAnimal; feedView.TotalCostForScheme = feed.TotalFeedingCost; feedView.NumIngredients = feed.NumberOfItems; } return(feedView); } }
public FeedingSchemePartialView GetFeedSchemeById(int id) { using (var feedSchemeRepo = new FeedingSchemeRepository()) { FeedingScheme feed = feedSchemeRepo.GetById(id); var feedView = new FeedingSchemePartialView(); if (feed != null) { feedView.FeedingSchemeId = feed.FeedingSchemeId; feedView.BatchTypeDesc = _bTypeRepo.GetAll().Find(j => j.BatchTypeid == feed.BatchTypeid).BatchTypeDesc; feedView.NoOfAnimals = feed.NoOfAnimals; feedView.DatePrepared = feed.DatePrepared; feedView.CostPerAnimal = feed.FeedCostPerAnimal; feedView.TotalCostForScheme = feed.TotalFeedingCost; feedView.NumIngredients = feed.NumberOfItems; } return feedView; } }
public void UpdateFeedScheme(FeedingSchemePartialView model) { using (var feedSchemeRepo = new FeedingSchemeRepository()) { FeedingScheme feed = feedSchemeRepo.GetById(model.FeedingSchemeId); if (feed != null) { feed.FeedingSchemeId = model.FeedingSchemeId; feed.NoOfAnimals = model.NoOfAnimals; feed.DatePrepared = model.DatePrepared; feed.NumberOfItems = model.NumIngredients; feed.SchemeCode = model.SchemeCode; feed.FeedCostPerAnimal = model.CostPerAnimal; feed.TotalFeedingCost = model.TotalCostForScheme; feedSchemeRepo.Update(feed); } } }