public HttpResponse GetCareerRatings(string user)
        {
            JavaScriptSerializer jss = new JavaScriptSerializer();

            StudentAccountClient    sac           = new StudentAccountClient();
            StudentAccount          student       = sac.GetByPartitionAndRowKey(StudentAccountClient.GetPartitionKeyForEmail(user), user);
            AssessmentCareerClient  acc           = new AssessmentCareerClient();
            List <AssessmentCareer> careerRatings = new List <AssessmentCareer>(acc.GetAllCurrentByStudent(student.School, user, student.Year, student.Grade));

            //StudentProfileClient spc = new StudentProfileClient();
            //StudentProfile student = spc.GetByPartitionAndRowKey(StudentProfileClient.GetPartitionKeyForEmail(user), user);
            //AssessmentCareerRatingClient acrc = new AssessmentCareerRatingClient();
            //List<AssessmentCareerRating> careerRatings =  new List<AssessmentCareerRating>(acrc.GetAllBySchoolAndStudent(student.School, user));
            List <CareerRating> results = new List <CareerRating>();
            string response;

            if (careerRatings.Count != 0)
            {
                foreach (AssessmentCareer careerRating in careerRatings)
                {
                    results.Add(new CareerRating {
                        dolcode = careerRating.DolCode, rating = careerRating.Value
                    });
                }
                response = "{\"result\": \"ok\", \"results\":" + jss.Serialize(results) + "}";
            }
            else
            {
                response = "{\"result\": \"ok\", \"results\":[]}";
            }
            Response.ContentType = "application/json";
            Response.Write(response);
            Response.End();
            return(null);
        }
        public void SaveCareerRating(string user, string career, string rating)
        {
            StudentAccountClient sac     = new StudentAccountClient();
            StudentAccount       student = sac.GetByPartitionAndRowKey(StudentAccountClient.GetPartitionKeyForEmail(user), user);

            if (student != null)
            {
                AssessmentCareerClient acc          = new AssessmentCareerClient();
                AssessmentCareer       careerRating = acc.GetByPartitionAndRowKey(student.School, user + student.Year + student.Grade + career);
                if (careerRating == null)
                {
                    acc.AddNewItem(new AssessmentCareer {
                        PartitionKey = student.School, RowKey = user + student.Year + student.Grade + career, Value = rating, Counselor = student.Counselor, Student = user, Grade = student.Grade, GroupName = student.GroupName, DolCode = career, Year = student.Year
                    });
                    //acrc.AddNewItem(new AssessmentCareerRating { PartitionKey = student.School, RowKey = user + career, DolCode = career, Rating = rating, GradYear = student.GradYear, Student = user, Teacher = student.Teacher, Group = student.Group });
                    if (rating == "1")
                    {
                        student.RatedCareers++;
                    }
                    else
                    {
                        student.DislikeCareers++;
                    }
                    sac.Update(student);
                }
                else
                {
                    if (careerRating.Value != rating)
                    {
                        if (rating == "1")
                        {
                            student.DislikeCareers--;
                            student.RatedCareers++;
                        }
                        else
                        {
                            student.DislikeCareers++;
                            student.RatedCareers--;
                        }
                        sac.Update(student);
                    }
                    careerRating.Value = rating;
                    acc.Update(careerRating);
                }
            }

            //StudentProfileClient spc = new StudentProfileClient();
            //StudentProfile student = spc.GetByPartitionAndRowKey(StudentProfileClient.GetPartitionKeyForEmail(user), user);
            //AssessmentCareerRatingClient acrc = new AssessmentCareerRatingClient();
            //AssessmentCareerRating careerRating = acrc.GetByPartitionAndRowKey(student.School, user + career);
        }
        public ActionResult Index()
        {
            string user = AuthTokens[1];

            StudentAccountClient      sac     = new StudentAccountClient();
            StudentAccount            student = sac.GetByPartitionAndRowKey(StudentAccountClient.GetPartitionKeyForEmail(user), user);
            AssessmentInterestClient  aic     = new AssessmentInterestClient();
            List <AssessmentInterest> importantThingRatings = new List <AssessmentInterest>(aic.GetAllCurrentByStudent(student.School, user, student.Year, student.Grade));
            AssessmentCareerClient    acc           = new AssessmentCareerClient();
            List <AssessmentCareer>   careerRatings = new List <AssessmentCareer>(acc.GetAllCurrentByStudent(student.School, user, student.Year, student.Grade));

            //StudentProfileClient spc = new StudentProfileClient();
            //StudentProfile student = spc.GetByPartitionAndRowKey(StudentProfileClient.GetPartitionKeyForEmail(user), user);
            //AssessmentInterestRatingClient airc = new AssessmentInterestRatingClient();
            //List<AssessmentInterestRating> importantThingRatings = new List<AssessmentInterestRating>(airc.GetAllBySchoolAndStudent(student.School, user));
            //AssessmentCareerRatingClient acrc = new AssessmentCareerRatingClient();
            //List<AssessmentCareerRating> careerRatings = new List<AssessmentCareerRating>(acrc.GetAllBySchoolAndStudent(student.School, user));
            ViewBag.CareersRated = careerRatings.Count == 0 ? "no" : "yes";
            ViewBag.School       = student.School;
            JavaScriptSerializer jss = new JavaScriptSerializer();

            ViewBag.interestsRated = jss.Serialize(importantThingRatings.Where(x => x.Value == "1").Select(x => x.Interest).ToList());
            if (importantThingRatings.Where(x => x.Value == "1").ToList().Count == 3)
            {
                ViewBag.ImportantThings = "yes";
            }
            else
            {
                ViewBag.ImportantThings = "no";
            }
            if (TempData["message"] != null)
            {
                ViewBag.Message = TempData["message"];
            }
            if (TempData["successmessage"] != null)
            {
                ViewBag.Successmessage = TempData["successmessage"];
            }
            ViewBag.UpdateAccessCode = student.Year != AccessCodeClient.CurrentGradYear();
            return(View());
        }