public ActionResult LoadIngredient(LoadIngredientModel input) { IngredientFactory IngFactory = new IngredientFactory(); POIngredientViewModels model = new POIngredientViewModels(); //var listIng = IngFactory.GetIngredient("").Where(x => x.IsActive).ToList(); var listIng = IngFactory.GetIngredientBySupplier(input.SupplierId, input.StoreId); foreach (var item in listIng) { model.ListItemView.Add(new POIngredient { BaseUOM = item.ReceivingUOMName, IngredientId = item.Id, IngredientName = item.Name, PurchasePrice = item.PurchasePrice, Description = item.Description, IngredientCode = item.Code, IngReceivingQty = item.ReceivingQty, Qty = item.ReOrderQty.HasValue ? item.ReOrderQty.Value : 0 }); } if (input.ListItemNew != null) { model.ListItemView = model.ListItemView.Where(x => !input.ListItemNew.Contains(x.IngredientId)).ToList(); } model.ListItemView = model.ListItemView.OrderByDescending(x => x.IsSelect ? 1 : 0).ThenBy(x => x.IngredientName).ToList(); return(PartialView("_TableChooseIngredient", model)); }
public ActionResult AddIngredient(POIngredientViewModels data) { WorkOrderModels model = new WorkOrderModels(); model.ListItem = new List <WOIngredient>(); foreach (var item in data.ListItemView) { model.ListItem.Add(new WOIngredient { Id = item.Id, // Add New IngredientId = item.IngredientId, IngredientName = item.IngredientName, IngredientCode = item.IngredientCode, Description = item.Description, IsSelect = item.IsSelect, Qty = item.Qty, UnitPrice = item.UnitPrice, Amount = item.Amount, BaseUOM = item.BaseUOM, IngReceivingQty = item.IngReceivingQty, Delete = item.Delete }); } return(PartialView("_ListItemNew", model)); }
public ActionResult AddIngredient(POIngredientViewModels data) { PurchaseOrderModels model = new PurchaseOrderModels(); model.ListItem = new List <POIngredient>(); //--------update bool IsIntegrate = false; bool _IsShowTax = false; var objStore = CurrentUser.listStore.Where(x => x.ID.Equals(data.StoreId)).FirstOrDefault(); if (objStore != null) { var objThirdParty = objStore.ThirdParty; if (objThirdParty != null && !string.IsNullOrEmpty(objThirdParty.ApiURL)) { IsIntegrate = objThirdParty.IsIntegrate; } } List <SelectListItem> listItemTax = new List <SelectListItem>(); if (IsIntegrate) { _IsShowTax = true; var lstTaxV2 = _factoryTax.GetListTaxV2(data.StoreId, null, CurrentUser.ListOrganizationId); lstTaxV2 = lstTaxV2.Where(x => x.IsActive).ToList(); if (lstTaxV2 != null) { foreach (Shared.Models.Settings.TaxModels tax in lstTaxV2) { listItemTax.Add(new SelectListItem { Text = tax.Name, Value = tax.ID, }); } } } //--------updated foreach (var item in data.ListItemView) { model.ListItem.Add(new POIngredient { Id = item.Id, // Add New IngredientId = item.IngredientId, IngredientName = item.IngredientName, IngredientCode = item.IngredientCode, Description = item.Description, IsSelect = item.IsSelect, Qty = item.Qty, UnitPrice = item.UnitPrice, Amount = item.Amount, BaseUOM = item.BaseUOM, IngReceivingQty = item.IngReceivingQty, Delete = item.Delete, //--updated TaxId = item.TaxId, TaxName = item.TaxName, TaxType = item.TaxType, TaxAmount = item.TaxAmount, TaxPercent = item.TaxPercent, ListTax = listItemTax, IsShowTax = _IsShowTax }); } return(PartialView("_ListItemNew", model)); }