Example #1
0
 public UnitOfWork()
 {
     _context = new ApplicationContext();
     _distributionRepository           = new DistributionRepository(_context);
     _distributionParametersRepository = new DistributionParametersRepository(_context);
     _experimentRepository             = new ExperimentRepository(_context);
     _percentageRepository             = new PercentageRepository(_context);
 }
Example #2
0
        public void DeletePercent(PercentageView model)
        {
            using (var percRepo = new PercentageRepository())
            {
                Percentage feed = percRepo.GetById(model.FeedingSchemeId);

                if (feed != null)
                {
                    percRepo.Delete(feed);
                }
            }
        }
Example #3
0
 public List <PercentagePartialView> GetAllIngredients()
 {
     using (var percRepo = new PercentageRepository())
     {
         return(percRepo.GetAll().Select(x => new PercentagePartialView
         {
             PercentageId = x.PercentageId,
             ItemName = _fStockRepo.GetAll().Find(j => j.FeedingStockId == x.FeedingStockId).ItemName,
             Percentage = x.PercentageRate,
             SchemeCode = _fSchemeRepo.GetAll().Find(j => j.FeedingSchemeId == x.FeedingSchemeId).SchemeCode
         }).ToList());
     }
 }
Example #4
0
 public void AddPercent(PercentageView model)
 {
     using (var percRepo = new PercentageRepository())
     {
         var ingPerc = new Percentage()
         {
             PercentageId    = model.PercentageId,
             FeedingStockId  = _fStockRepo.GetAll().Find(x => x.FeedingStockId == model.FeedingStockId).FeedingStockId,
             PercentageRate  = model.Percentage,
             FeedingSchemeId = _fSchemeRepo.GetAll().Find(p => p.FeedingSchemeId == model.FeedingSchemeId).FeedingSchemeId
         };
         percRepo.Insert(ingPerc);
         CalcIngredientCost(model);
     }
 }
Example #5
0
        public PercentagePartialView GetPercView(int id)
        {
            using (var ingreRepo = new PercentageRepository())
            {
                Percentage perc = ingreRepo.GetById(id);

                var ingredView = new PercentagePartialView();

                if (perc != null)
                {
                    ingredView.PercentageId = perc.PercentageId;
                    ingredView.ItemName     =
                        _fStockRepo.GetAll().Find(j => j.FeedingStockId == perc.FeedingStockId).ItemName;
                    ingredView.Percentage = perc.PercentageRate;
                    ingredView.SchemeCode =
                        _fSchemeRepo.GetAll().Find(j => j.FeedingSchemeId == perc.FeedingSchemeId).SchemeCode;
                }
                return(ingredView);
            }
        }