コード例 #1
0
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            JobOpening job = db.Job(id.Value);

            if (job == null)
            {
                return(HttpNotFound());
            }
            JobOpeningViewModel jobVM = MapJobOpening(job);

            //Moved here in order to prevent multiple concurrent read actions
            jobVM.Applicants = job.GetAllApplicants().Select(a => new ApplicantViewModel()
            {
                Email          = a.Email,
                DepartmentName = a.GetDepartmentName(),
                CVID           = a.GetMostRecentCVID()
            });
            jobVM.Messages = job.Messages
                             .Where(m => m.IsFirstMessage)
                             .Select(m => new MessageViewModel()
            {
                SenderName = m.Sender.UserName, RecipientName = m.Recipient.UserName, SendTime = m.SendTime, BodyContent = m.BodyContent
            });
            return(View(jobVM));
        }