public void ApplyBitterToRecipe() { RecipeFactory myFactory = new RecipeFactory(); IRecipe myRecipe = myFactory.GetRecipe(RecipeTypes.Beer); IngredientFactory myIngredientFactory = new IngredientFactory(); var ingredient = myIngredientFactory.GetIngredient(IngredientType.Fermentable); ingredient.Amount = 10; (ingredient as IFermentable).DiastaticPower = 1.04; myRecipe.Ingredients.Add(ingredient); //adding bitters is just a test for my sanity in querying interfaces and dealing with Covariance //note it will be repeated on the IBU calculation as the fermentable power impacts bitterness ingredient = myIngredientFactory.GetIngredient(IngredientType.BitterSeason); ingredient.Amount = 1.5; (ingredient as IBitter).BitteringFactor = 15; (ingredient as IBitter).BitterCalculationTime = 60; myRecipe.Ingredients.Add(ingredient); myRecipe.BatchVolume = 6.5; myRecipe.TotalEfficiencyPercent = 70; var ibus = myRecipe.GetEstimatedBitterness(); Assert.AreEqual(myRecipe.Bitters.Count, 1); //May need to check formula. BeerSmith usually is a little higher. BeerSmith has been known to tweak their forumulas though. Assert.AreEqual(63.81, Math.Round(ibus, 2)); }
public ActionResult LoadIngredient(string ProductId, string StoreId, int productType) { IngredientFactory IngFactory = new IngredientFactory(); var listProductRecipe = _factory.GetListRecipeProduct(ProductId, StoreId, productType, listStoreId); RecipeProductIngredientViewModels model = new RecipeProductIngredientViewModels(); var m_CompanyIds = GetListCompany().Select(x => x.Value).ToList(); var listIng = new List <IngredientModel>(); if (m_CompanyIds.Count > 0) { listIng = IngFactory.GetIngredient("").Where(x => m_CompanyIds.Contains(x.CompanyId)).ToList(); } else { listIng = IngFactory.GetIngredient("").ToList(); } listIng = listIng.Where(x => x.IsActive == true).ToList(); foreach (var item in listIng) { var ProIngre = new ProductIngredient() { BaseUOM = item.BaseUOMName, IngredientId = item.Id, IngredientName = item.Name, Usage = listProductRecipe.Where(x => x.IngredientId.Equals(item.Id)).FirstOrDefault() == null ? 0 : listProductRecipe.FirstOrDefault(x => x.IngredientId.Equals(item.Id)).Usage, BaseUOMId = listProductRecipe.Where(x => x.IngredientId.Equals(item.Id)).FirstOrDefault() == null ? item.BaseUOMId : listProductRecipe.FirstOrDefault(x => x.IngredientId.Equals(item.Id)).UOMId, IsSelect = listProductRecipe.Any(x => x.IngredientId.Equals(item.Id)) }; var lstItem = _UOMFactory.GetDataUOMRecipe(item.Id).ToList(); if (lstItem != null) { foreach (UnitOfMeasureModel uom in lstItem) { ProIngre.ListUOM.Add(new SelectListItem { Text = uom.Name, Value = uom.Id, Selected = uom.Id.Equals(ProIngre.BaseUOMId) == true ? true : false }); } } model.ListItem.Add(ProIngre); } model.ListItem = model.ListItem.OrderByDescending(x => x.IsSelect ? 1 : 0).ThenBy(x => x.IngredientName).ToList(); return(PartialView("_TableChooseIngredient", model)); }
public bool PushDataToXero(UsageManagementRequest request) { bool result = true; if (IsPush(request.DateTo, request.StoreId)) { //List<UsageManagementModel> lstCalResult = CalUsageManagementwithoutDetail(request); List <UsageManagementModel> lstCalResult = GetUsageManagement(request); //lstCalResult.Add(new UsageManagementModel() //{ // Code = "008", // Usage = 2 //}); try { IngredientSyncRequestDTO model = new IngredientSyncRequestDTO(); model.AppRegistrationId = Commons.XeroRegistrationAppId; model.AccessToken = Commons.XeroAccessToken; model.StoreId = request.StoreId; var lstIngredient = _ingredientFactory.GetIngredient(null); if (lstIngredient != null && lstIngredient.Count > 0) { lstIngredient = lstIngredient.Where(ww => !string.IsNullOrEmpty(ww.XeroId)).ToList(); if (lstIngredient != null && lstIngredient.Count > 0) { foreach (var item in lstCalResult) { var obj = lstIngredient.Where(ww => ww.Code.ToUpper().Equals(item.Code.ToUpper())).FirstOrDefault(); if (obj != null) { model.Items.Add(new IngredientUsageSyncItem() { Id = obj.XeroId, Code = obj.Code, QuantityUsed = (decimal)item.Usage }); } } if (model.Items != null && model.Items.Count > 0) { result = XeroFactory.SyncIngredientsUsageToXero(request.DateTo, request.StoreId, model).Result; } } } } catch (Exception ex) { result = false; _logger.Error(ex); } } return(result); }
public void ApplyFermentableToRecipe() { RecipeFactory myFactory = new RecipeFactory(); IRecipe myRecipe = myFactory.GetRecipe(RecipeTypes.Beer); IngredientFactory myIngredientFactory = new IngredientFactory(); var ingredient = myIngredientFactory.GetIngredient(IngredientType.Fermentable); ingredient.Amount = 10; (ingredient as IFermentable).DiastaticPower = 1.04; myRecipe.Ingredients.Add(ingredient); //adding bitters is just a test for my sanity in querying interfaces and dealing with Covariance //note it will be repeated on the IBU calculation as the fermentable power impacts bitterness ingredient = myIngredientFactory.GetIngredient(IngredientType.BitterSeason); ingredient.Amount = 1.5; myRecipe.Ingredients.Add(ingredient); myRecipe.BatchVolume = 6.5; myRecipe.TotalEfficiencyPercent = 70; var og = myRecipe.GetEstimatedOriginalGravity(); Assert.AreEqual(myRecipe.Fermentables.Count, 1); Assert.AreEqual(Math.Round(og, 3), 1.043); }
public SupplierModels GetDetail(string id) { try { SupplierModels model = _factory.GetDetail(id); if (!string.IsNullOrEmpty(model.CompanyId)) { model.CompanyName = lstCompany.Where(z => z.Value.Equals(model.CompanyId)).FirstOrDefault().Text; } //============= var ListSupIng = _IngredientSupplierFactory.GetDataForSupplier(model.Id, model.CompanyId); var ListIng = _ingredientFactory.GetIngredient(null).Where(x => x.IsActive).ToList(); foreach (var item in ListIng) { model.ListSupIng.Add(new Ingredients_SupplierModel { IngredientId = item.Id, IngredientName = item.Name, IngredientCode = item.Code, //IsCheck = ListSupIng.Any(z => z.Equals(item.Id)), IsActived = ListSupIng.Any(x => x.Equals(item.Id)), }); } //model.ListSupIng.ForEach(x => //{ // x.IsCheck = ListSupIng.Any(z => z.Equals(x.IngredientId)); //}); model.ListSupIng = model.ListSupIng.Where(x => x.IsActived).OrderByDescending(x => x.IsActived ? 1 : 0).ThenBy(x => x.IngredientName).ToList(); //model.ListSupIng = model.ListSupIng.OrderByDescending(x => x.IsActived ? 1 : 0).ThenBy(x => x.IngredientName).ToList(); return(model); } catch (Exception ex) { _logger.Error("SupplierDetail: " + ex); return(null); } }
public void ApplyFermenterToRecipe() { RecipeFactory myFactory = new RecipeFactory(); IRecipe myRecipe = myFactory.GetRecipe(RecipeTypes.Beer); IngredientFactory myIngredientFactory = new IngredientFactory(); var ingredient = myIngredientFactory.GetIngredient(IngredientType.Fermentable); ingredient.Amount = 10; (ingredient as IFermentable).DiastaticPower = 1.04; myRecipe.Ingredients.Add(ingredient); myRecipe.BatchVolume = 6.5; myRecipe.TotalEfficiencyPercent = 70; var og = myRecipe.GetEstimatedOriginalGravity(); Assert.AreEqual(myRecipe.Fermentables.Count, 1); Assert.AreEqual(Math.Round(og, 3), 1.043); ingredient = myIngredientFactory.GetIngredient(IngredientType.Fermenter); (ingredient as IFerment).PitchType = FermenterPitchType.Dry; (ingredient as IFerment).Attenuation = 75; myRecipe.Ingredients.Add(ingredient); var fg = myRecipe.GetEstimatedFinalGravity(); Assert.AreEqual(Math.Round(fg, 3), 1.011); }
public void CreateNewRecipe() { RecipeFactory myFactory = new RecipeFactory(); IRecipe myRecipe = myFactory.GetRecipe(RecipeTypes.Beer); myRecipe.BatchVolume = 6.5; myRecipe.Name = "My Beer Name"; myRecipe.TotalEfficiencyPercent = 70; myRecipe.Style = new Style(); IngredientFactory myIngredientFactory = new IngredientFactory(); myRecipe.Ingredients.Add(myIngredientFactory.GetIngredient(IngredientType.Fermentable)); myRecipe.BatchVolume = 6.5; Assert.AreEqual(1, myRecipe.Ingredients.Count); }
public ActionResult LoadIngredient(ReceiptNoteModels data) { IngredientFactory IngFactory = new IngredientFactory(); //Get Data from Client List <ReceiptNoteIngredient> listReceiptNoteIngre = listReceiptNoteIngre = data.ListItem; ReceiptNoteModels model = new ReceiptNoteModels(); //var m_CompanyIds = GetListCompany().Select(x => x.Value).ToList(); //var listIng = new List<IngredientModel>(); //if (m_CompanyIds.Count > 0) // listIng = IngFactory.GetIngredient("").Where(x => m_CompanyIds.Contains(x.CompanyId)).ToList(); //else // listIng = IngFactory.GetIngredient("").ToList(); ////==== Only get list Ingredients of the company of Receipt Note Store var lstStoreInfo = (List <StoreModels>)ViewBag.StoreID.Items; var compId = lstStoreInfo.Where(w => w.Id == data.StoreId).Select(s => s.CompanyId).FirstOrDefault(); var listIng = new List <IngredientModel>(); if (!string.IsNullOrEmpty(compId)) { listIng = _IngredientFactory.GetIngredient("").Where(x => x.CompanyId == compId).ToList(); if (listIng != null && listIng.Any()) { listIng = listIng.Where(x => x.IsActive == true && !x.IsSelfMode).ToList(); foreach (var item in listIng) { var ProIngre = new ReceiptNoteIngredient() { BaseUOM = item.BaseUOMName, IngredientId = item.Id, IngredientCode = item.Code, IngredientName = item.Name, Description = item.Description, //=======Set Qty Qty = listReceiptNoteIngre.Where(x => x.IngredientId.Equals(item.Id)).FirstOrDefault() == null ? 1 : listReceiptNoteIngre.FirstOrDefault(x => x.IngredientId.Equals(item.Id)).Qty, //=====Set UOM: Priority| ReceivingUOM -> BaseUOM BaseUOMId = listReceiptNoteIngre.Where(x => x.IngredientId.Equals(item.Id)).FirstOrDefault() != null ? listReceiptNoteIngre.FirstOrDefault(x => x.IngredientId.Equals(item.Id)).BaseUOMId : item.ReceivingUOMId, //=======Set Ing Select IsSelect = listReceiptNoteIngre.Any(x => x.IngredientId.Equals(item.Id)) }; var lstItem = _UOMFactory.GetDataUOMRecipe(item.Id).ToList(); if (lstItem != null) { foreach (UnitOfMeasureModel uom in lstItem) { ProIngre.ListUOM.Add(new SelectListItem { Text = uom.Name, Value = uom.Id, //Selected = uom.Id.Equals(ProIngre.BaseUOMId) ? true : false }); } //=====Reset UOM from BaseUOM If lstItemUOM not ReceivingUOM var isExists = lstItem.Exists(z => z.Id.Equals(ProIngre.BaseUOMId)); if (!isExists) { ProIngre.BaseUOMId = item.BaseUOMId; } } //====== model.ListItem.Add(ProIngre); } model.ListItem = model.ListItem.OrderByDescending(x => x.IsSelect ? 1 : 0).ThenBy(x => x.IngredientName).ToList(); } } return(PartialView("_TableChooseIngredient", model)); }