Ejemplo n.º 1
0
        internal static TblReservationMainDetailsViewModel MaptoViewModel(Tbl_ReservationMainDetails resRow, ObservableCollection <Fabric_UnitID> mainFabricList, ObservableCollection <GetItemOnhand_Result> onHandList)
        {
            var detailsList = new ObservableCollection <TblReservationDetailsViewModel>();

            foreach (var row in resRow.Tbl_ReservationDetails)
            {
                var newDetail = new TblReservationDetailsViewModel();
                GenericMapper.InjectFromObCollection(newDetail.ReservationListRec, row.Tbl_ReservationRec);
                newDetail.InjectFrom(row);
                detailsList.Add(newDetail);
            }

            double onhand = 0;

            try
            {
                onhand = Convert.ToDouble(onHandList.FirstOrDefault(w => w.FabricCode == resRow.Fabric && w.CONFIGID == resRow.FabricColor && w.TOBATCH == resRow.Batchno).Qty);
            }
            catch (Exception)
            {
                onhand = 0;
            }

            var newRow = new TblReservationMainDetailsViewModel();

            newRow.InjectFrom(resRow);
            newRow.ReservationDetailsViewModelList = detailsList;
            newRow.RemQtyTemp = newRow.Qty - newRow.ReservationDetailsViewModelList.Sum(x => x.IntialQty);
            newRow.RemQty     = newRow.RemQtyTemp;
            newRow.OnHandQty  = onhand;
            //  newRow.FabricName = mainFabricList.FirstOrDefault(x => x.Fabric_Code == newRow.Fabric).Fabric_Ename;
            return(newRow);
        }
Ejemplo n.º 2
0
        public static TblReservationMainDetailsViewModel MaptoViewModel(Tbl_ReservationMainDetails resRow, ObservableCollection <Fabric_UnitID> mainFabricList)
        {
            var detailsList = new ObservableCollection <TblReservationDetailsViewModel>();

            foreach (var row in resRow.Tbl_ReservationDetails)
            {
                var newDetail = new TblReservationDetailsViewModel();
                GenericMapper.InjectFromObCollection(newDetail.ReservationListRec, row.Tbl_ReservationRec);
                newDetail.InjectFrom(row);
                detailsList.Add(newDetail);
            }

            var newRow = new TblReservationMainDetailsViewModel();

            newRow.InjectFrom(resRow);
            newRow.ReservationDetailsViewModelList = detailsList;
            newRow.RemQtyTemp = newRow.Qty - newRow.ReservationDetailsViewModelList.Sum(x => x.IntialQty);
            newRow.RemQty     = newRow.RemQtyTemp;
            //  newRow.FabricName = mainFabricList.FirstOrDefault(x => x.Fabric_Code == newRow.Fabric).Fabric_Ename;
            return(newRow);
        }