예제 #1
0
 public List <FeedingRatioView> GetAllFeedRatio()
 {
     using (var feedRatio = new FeedingRatioRepository())
     {
         return(feedRatio.GetAll().Select(x => new FeedingRatioView
         {
             FeedingRatioId = x.FeedingRatioId,
             ProductName = x.ProductName,
             ProductMass = x.ProductMass
         }).ToList());
     }
 }
예제 #2
0
 public FeedingRatioView GetFeedRatioById(int id)
 {
     using (var feedRatio = new FeedingRatioRepository())
     {
         var feed     = feedRatio.GetById(id);
         var feedView = new FeedingRatioView();
         if (feed != null)
         {
             feedView.FeedingRatioId = feed.FeedingRatioId;
             feedView.ProductMass    = feed.ProductMass;
             feedView.ProductName    = feed.ProductName;
         }
         return(feedView);
     }
 }
예제 #3
0
        public void AddFeedRatio(FeedingRatioView model)
        {
            using (var feedRatio = new FeedingRatioRepository())
            {
                //from ingredients
                double totalIngredientsMass = _ingredients.GetAll().Sum(x => Convert.ToDouble(x.IngredientMass));

                var feed = new FeedingRatio
                {
                    FeedingRatioId = model.FeedingRatioId,
                    ProductName    = model.ProductName,
                    ProductMass    = totalIngredientsMass.ToString(CultureInfo.InvariantCulture) + " Kg."
                };
                feedRatio.Insert(feed);
                DeleteAllIngredientsFromList();
            }
        }