public ActionResult AddIngredient(STIngredientViewModels data) { StockTransferModels model = new StockTransferModels(); model.ListItem = new List <StockTransferDetailModels>(); foreach (var item in data.ListItemView) { var itemDetail = new StockTransferDetailModels { Id = "", // Add New IngredientId = item.IngredientId, IngredientName = item.IngredientName, IngredientCode = item.IngredientCode, IsSelect = item.IsSelect, RequestQty = item.RequestQty, IssueQty = item.IssueQty, ReceiveQty = item.ReceiveQty, UOMId = item.UOMId, BaseUOM = item.BaseUOM, }; var lstItem = _UOMFactory.GetDataUOMRecipe(item.IngredientId).ToList(); if (lstItem != null) { foreach (UnitOfMeasureModel uom in lstItem) { itemDetail.ListUOM.Add(new SelectListItem { Text = uom.Name, Value = uom.Id }); } } model.ListItem.Add(itemDetail); } return(PartialView("_ListIngredients", model)); }
public ActionResult LoadIngredient(List <string> ListItemNew, string IssuingStoreId) { STIngredientViewModels model = new STIngredientViewModels(); var listIng = _InventoryFactory.LoadIngredient(IssuingStoreId); foreach (var item in listIng) { var itemDetail = new StockTransferDetailModels { UOMId = item.BaseUOMId, BaseUOM = item.BaseUOMName, IngredientId = item.Id, IngredientName = item.Name, IngredientCode = item.Code }; model.ListItemView.Add(itemDetail); } if (ListItemNew != null) { model.ListItemView = model.ListItemView.Where(x => !ListItemNew.Contains(x.IngredientId)).ToList(); } model.ListItemView = model.ListItemView.OrderByDescending(x => x.IsSelect ? 1 : 0).ThenBy(x => x.IngredientName).ToList(); return(PartialView("_TableChooseIngredient", model)); }