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 ActionResult AddPercentage(PercentageView model)
        {
            if (ModelState.IsValid)
            {
                FeedingStockBussiness fStock = new FeedingStockBussiness();
                ViewBag.FeedingStockId = new SelectList(fStock.GetAllFeedingStock(), "FeedingStockId", "ItemName");
                FeedingSchemeBl fScheme = new FeedingSchemeBl();
                ViewBag.FeedingSchemeId = new SelectList(fScheme.GetAllFeedSchemeViews(), "FeedingSchemeId", "SchemeCode");

                PercentageBl percBl=new PercentageBl();

                if (percBl.IsAvailable(model))
                {
                    percBl.AddPercent(model);
                    return RedirectToAction("GetAllPercentage");
                }

                return RedirectToAction("ValidateAvailable");
            }

            return View();
        }
        public int IngredientCount(FeedingSchemeView model)
        {
            PercentageBl percBl = new PercentageBl();

            return(percBl.GetAllIngredients().Count(j => j.SchemeCode == model.SchemeCode));
        }
 // GET: Percentage
 public ActionResult GetAllPercentage()
 {
     var percBl= new PercentageBl();
     return View(percBl.GetAllIngredients());
 }
        public int IngredientCount(FeedingSchemeView model)
        {
            PercentageBl percBl= new PercentageBl();

            return percBl.GetAllIngredients().Count(j => j.SchemeCode == model.SchemeCode);
        }