public ActionResult Delete(int id)
 {
     var repo = new BatchTypeRepository();
     var _batchtypelog = new BatchTypeBl();
     var batchview = _batchtypelog.GetBatchTypeById(id);
     _batchtypelog.Delete(batchview);
     return RedirectToAction("GetAllBatchType");
 }
        public IEnumerable <SelectListItem> PopulateDropDownList(object selectedCategory = null)
        {
            var db2        = new BatchTypeBl();
            var batchtypes = db2.GetAllBatchTypes().Select(b => new SelectListItem
            {
                Value = b.BatchTypeid.ToString(CultureInfo.InvariantCulture),
                Text  = b.BatchTypeDesc
            });

            return(batchtypes);
        }
        public List <BatchView> SearchByDescOfbatch(string searchstring)
        {
            var batchType = new BatchTypeBl();

            return((from b in GetAllBatches()
                    let cat = batchType.GetBatchTypeById(b.BatchTypeid)
                              where cat.BatchTypeDesc.ToLower().Contains(searchstring.ToLower()) ||
                              b.BatchCode.ToLower().Contains(searchstring.ToLower())

                              select b).ToList());
        }
        private static Batch ConvertBatch(BatchView batchView, String userId)
        {
            var bty  = new BatchTypeBl();
            var user = _db.Users.ToList().Find(x => x.Id == userId);

            var batch = new Batch
            {
                Batchid      = batchView.Batchid,
                BatchTypeid  = batchView.BatchTypeid,
                UserId       = batchView.UserId,
                Name         = user.UserProfile.FirstName,
                BatchCode    = bty.GetBatchTypeById(batchView.BatchTypeid).BatchTypeDesc.Substring(0, 2) + DateTime.Now,
                Agerange     = batchView.Agerange,
                NumOfAnimals = batchView.NumOfAnimals,
                Wiegth       = batchView.Wiegth,
                Totalcost    = batchView.Totalcost
            };

            return(batch);
        }
 //Single Batchtype
 public ActionResult Details(int id)
 {
     var batchtypelog = new BatchTypeBl();
     return View(batchtypelog.GetBatchTypeById(id));
 }
 //Edit BatchType
 public ActionResult Delete(int? id)
 {
     var _batchtypelog = new BatchTypeBl();
     var batchview = _batchtypelog.GetAllBatchTypes().Find(x => x.BatchTypeid == id);
     return View(batchview);
 }
        //Method to get number of animals currently in feeding lots
        private static int CalcAniFeeding(FeedingSchemeView model)
        {
            AnimalBusiness aniBl = new AnimalBusiness();
            BatchTypeBl batchTypeBl = new BatchTypeBl();
            var bDesc = batchTypeBl.GetAllBatchTypes().Find(x=>x.BatchTypeid== model.BatchTypeid);

            return (aniBl.GetAllAnimals().Count(animalpar => animalpar.AniFeedingStatus == "FeedLot"
                         && animalpar.BatchTypeDesc==bDesc.BatchTypeDesc));
        }