private LCM_BillofLadingContainer BillOfLadingContainerModelConverter(LcmBillOfLadingContainerVM model, int userId, int blid) { var entity = model.BlcCntId == 0 ? new LCM_BillofLadingContainer() : (from b in _context.LCM_BillofLadingContainer.AsEnumerable() where b.BLCcntID == model.BlcCntId select b).FirstOrDefault(); entity.BLCcntID = model.BlcCntId; entity.BLID = blid; entity.ContainerNo = model.ContainerNo; entity.ContainerType = model.ContainerType; entity.SealNo = model.SealNo; entity.PackageQty = model.PackageQty; entity.GrossWeight = model.GrossWeight; entity.WeightUnit = model.WeightUnit; if (model.BlcCntId == 0) { entity.SetBy = userId; entity.SetOn = DateTime.Now; } else { entity.ModifiedOn = DateTime.Now; entity.ModifiedBy = userId; } return(entity); }
public ActionResult GetBillOfLadingById(int blid) { var blEntity = _unit.BillOfLadingRepository.GetByID(blid); var blModel = new LcmBillOfLadingVM(); blModel.Blid = blEntity.BLID; blModel.BlNo = blEntity.BLNo; blModel.BlDate = string.Format("{0:dd/MM/yyyy}", blEntity.BLDate); blModel.Lcid = blEntity.LCID; blModel.LcNo = blEntity.LCNo; blModel.CIID = blEntity.CIID; blModel.CINo = blEntity.CINo; blModel.ShippedOnBoardDate = string.Format("{0:dd/MM/yyyy}", blEntity.ShippedOnBoardDate); blModel.ExpectedArrivalTime = string.Format("{0:dd/MM/yyyy}", blEntity.ExpectedArrivalTime); blModel.Shipper = blEntity.Shipper; blModel.ShipmentMode = blEntity.ShipmentMode; blModel.VesselName = blEntity.VesselName; blModel.VoyageNo = blEntity.VoyageNo; blModel.TransShipmentPort = blEntity.TransShipmentPort; blModel.ShipmentPort = blEntity.ShipmentPort; blModel.RecordStatus = blEntity.RecordStatus; blModel.Containers = new List <LcmBillOfLadingContainerVM>(); if (blEntity.LCID != null) { blModel.PiNo = _unit.LCOpeningRepository.GetByID(blEntity.LCID).PINo; } if (blEntity.Shipper != null) { blModel.ShipperName = _unit.SysBuyerRepository.GetByID(blEntity.Shipper).BuyerName; } if (blEntity.TransShipmentPort != null) { blModel.TransShipmentPortName = _unit.SysPortRepository.GetByID(blEntity.TransShipmentPort).PortName; } if (blEntity.ShipmentPort != null) { blModel.ShipmentPortName = _unit.SysPortRepository.GetByID(blEntity.ShipmentPort).PortName; } var blcEntity = _unit.BillOfLadingContainerRepository.Get().Where(ob => ob.BLID == blid).ToList(); foreach (var entity in blcEntity) { var blcModel = new LcmBillOfLadingContainerVM(); blcModel.BlcCntId = entity.BLCcntID; blcModel.Blid = entity.BLID; blcModel.ContainerNo = entity.ContainerNo; blcModel.ContainerType = entity.ContainerType; blcModel.SealNo = entity.SealNo; blcModel.PackageQty = entity.PackageQty; blcModel.GrossWeight = entity.GrossWeight; blcModel.WeightUnit = entity.WeightUnit; if (entity.WeightUnit != null) { blcModel.WeightUnitName = _unit.SysUnitRepository.GetByID(entity.WeightUnit).UnitName; } blModel.Containers.Add(blcModel); } return(Json(blModel, JsonRequestBehavior.AllowGet)); }