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()); } }
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); } }
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(); } }