using BPASmartClient.FoodStationTest.Model; using BPA.Helper; using BPA.Helper; using System; using System.Collections.ObjectModel; using System.Linq; namespace BPASmartClient.FoodStationTest.ViewModel { public class RecipeInfosViewModel : NotifyBase { public RecipeInfosViewModel() { ActionManage.GetInstance.CancelRegister("RecipeInfo"); ActionManage.GetInstance.Register(new Action((o) => { if (o != null && o is RemoteRecipeData rm) { RecipeName = rm.RecipeName; RecipeCode = rm.RecipeCode; TrayCode = rm.TrayCode; foreach (var item in rm.RawMaterial) { //RawMaterialsInfo.Add(item); var res = Json.Data.rawMaterialStockBin.FirstOrDefault(p => p.RawMaterialLocation == item.RawMaterialLocation); if (res != null && !string.IsNullOrEmpty(res.RawMaterialName)) { var temp = Json.Data.BomMaterial.FirstOrDefault(p => p.MaterialCode == res.RawMaterialName); if (temp != null && !string.IsNullOrEmpty(temp.MaterialName)) { item.RawMaterialName = temp.MaterialName; } } RawMaterialsInfo.Add(new RemoteRecipeRawMaterial() { RawMaterialType = item.RawMaterialType, RawMaterialName = item.RawMaterialName, RawMaterialWeight = item.RawMaterialWeight, RawMaterialLocation = item.RawMaterialLocation, RawMaterialBarrelNum = item.RawMaterialBarrelNum, }); } } }), "RecipeInfo"); ReturnPage = new BPARelayCommand(() => { ActionManage.GetInstance.Send("CloseRecipeInfosView"); }); } public string RecipeName { get { return _mRecipeName; } set { _mRecipeName = value; OnPropertyChanged(); } } private string _mRecipeName; public string RecipeCode { get { return _mRecipeCode; } set { _mRecipeCode = value; OnPropertyChanged(); } } private string _mRecipeCode; public int TrayCode { get { return _mTrayCode; } set { _mTrayCode = value; OnPropertyChanged(); } } private int _mTrayCode; public BPARelayCommand ReturnPage { get; set; } public ObservableCollection RawMaterialsInfo { get; set; } = new ObservableCollection(); } }