public ManagerViewModel( User user, Review review)
 {
     UserName = user.UserName;
     if (review != null)
     {
         StageOne = review.DateCreated.ToShortDateString();
         StageTwo = review.StageTwoComplete;
         ReviewID = review.StageOneComplete ? review.ID : 0;
     }
 }
        // GET: Reviews
        public async Task<ActionResult> Index()
        {
            var username = GetUserName();
            
            //find self review
            //filter for this year.
            var review = db.Reviews.Include(u => u.User).Where(u => u.User.UserName == username).FirstOrDefault();

            //if not found, create, populate and save
            if (review == null)
            {
                var user = db.Users.Where(u => u.UserName == username).FirstOrDefault();

                if (user == null)
                {
                    return View("Error");
                }

                //throw error if user not found
                review = new Review();
                review.UserID = user.ID;
                review.DateCreated = DateTime.Now;
                review.StageOneComplete = false;
                review.StageTwoComplete = false;              
                db.Reviews.Add(review);
                await db.SaveChangesAsync();

                var questions = db.Questions.Where(q => q.TemplateYear == "2015").OrderBy( q => q.Order );
                foreach( var q in questions)
                {
                    if (q.ManagerOnly)
                    {
                        var reviewQuestion = new ReviewQuestionManager { QuestionID = q.ID, ReviewID = review.ID };
                        db.ReviewQuestionManagers.Add(reviewQuestion);
                    }
                    else
                    {
                        var reviewQuestion = new ReviewQuestionEmployee { QuestionID = q.ID, ReviewID = review.ID };
                        db.ReviewQuestionEmployees.Add(reviewQuestion);
                    }
                }
                await db.SaveChangesAsync();                
            }

            if (review.StageOneComplete)
            {                
                return RedirectToAction("Thankyou", "Reviews");
            } 
            else
            {
                ViewBag.HideHeader = true;
                ViewBag.FinaliseMode = false;
                return View(review);
            }
        }
        public async Task<ActionResult> Index( Review review)
        {
            if (ModelState.IsValid)
            {
                review.StageOneComplete = true;
                db.Entry(review).State = EntityState.Modified;

                foreach( var q in review.ReviewQuestionEmployees)
                    db.Entry(q).State = EntityState.Modified;

                await db.SaveChangesAsync();

                return RedirectToAction("Thankyou", "Reviews");
            }

            ViewBag.FinaliseMode = false;
            return View(review);
        }