Solved

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

Posted on 2014-09-07
1
174 Views
Last Modified: 2016-02-17
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?
0
Comment
Question by:jabz ayuap
1 Comment
 

Accepted Solution

by:
jabz ayuap earned 0 total points
ID: 40309209
I got my answer already obj.EmployeeId = (vess == null) ? obj.EmployeeId = 0 : obj.EmployeeId = vess.EmployeeProfileId; this solve my problem
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Article by: Nadia
Suppose you use Uber application as a rider and you request a ride to go from one place to another. Your driver just arrived at the parking lot of your place. The only thing you know about the ride is the license plate number. How do you find your U…
The greatest common divisor (gcd) of two positive integers is their largest common divisor. Let's consider two numbers 12 and 20. The divisors of 12 are 1, 2, 3, 4, 6, 12 The divisors of 20 are 1, 2, 4, 5, 10 20 The highest number among the c…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now