public ActionResult ViewJob(int jobId) { string UserId = User.Identity.GetUserId(); var model = new JobViewModel(); LogicService cmLogic = new LogicService(); //Check if job is completed bool jobCompleted = cmLogic.JobCompletionStatus(jobId.ToString(), UserId); if (!jobCompleted) { //Acquire job from logic var jobsForUser = cmLogic.GetJobsForUser(UserId); var matchingJob = jobsForUser.Where(j => j.Id == jobId); if (matchingJob.Count() > 0) { var job = matchingJob.First(); model.ServiceType = job.type.Name; model.ClientName = job.client.Name; model.Duration = job.EstimatedDuration.ToString(); model.Notes = job.Notes; model.Completed = job.Complete ? "Complete" : "Incomplete"; model.StartDate = job.StartDate; model.JobId = job.Id.ToString(); return(View(model)); } else { return(RedirectToAction("Result", "Dashboard", new { statusCode = 1, message = "Unable To Access Job Information" })); } } else { //Generate invoice for job Invoice jobInvoice = cmLogic.GetJobInvoice(jobId.ToString(), UserId); if (jobInvoice != null) { //Display invoice for job model.JobInvoice = jobInvoice; return(View(model)); } else { return(RedirectToAction("Result", "Dashboard", new { statusCode = 1, message = "Unable To Access Job Information" })); } } }