Link to home
Start Free TrialLog in
Avatar of jabz ayuap
jabz ayuap

asked on

How can I set in mvc viewmodel my id if id = 0 and if id.hasvalue id = id.value

I have   CrewPerVessel vess = new CrewPerVessel();
                        vess = _crewperVesselRepository.GetFirstItem(x => x.CrewPerVesselId == crewpergroup.CrewId && x.EmployeeProfilePersonalDetail.Position.PositionName == "Boat Captain");

and i have  obj.id = (vess.id == null)? vess.id = 0 : obj.id = vess.id

after running the execution if i got object not reference to object and i know this code above obj.id = (vess.id == null)? vess.id = 0 : obj.id = vess.id makes my project stop. Can you help me guys if how can make this work?
ASKER CERTIFIED SOLUTION
Avatar of jabz ayuap
jabz ayuap

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial