public ActionResult AddPercentage()
 {
     FeedingStockBussiness fStock = new FeedingStockBussiness();
     ViewBag.FeedingStockId = new SelectList(fStock.GetAllFeedingStock(),"FeedingStockId","ItemName");
     FeedingSchemeBl fScheme = new FeedingSchemeBl();
     ViewBag.FeedingSchemeId = new SelectList(fScheme.GetAllFeedSchemeViews(), "FeedingSchemeId", "SchemeCode");
     return View();
 }
        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();
        }
        //Method to validate if stock items exist from which a percenatge can be obtained from
        public bool IsAvailable(PercentageView model)
        {
            var available = false;

            FeedingStockBussiness stockItem= new FeedingStockBussiness();

            FeedingStockView stockView = stockItem.GetFeedingStockById(model.FeedingStockId);

            if (stockView != null)
                if (stockView.NumberOfItems >= 1)
                           available = true;

            return available;
        }