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
193 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…

717 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