Exemple #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            mUser = (AppUser)Session[Constants.SESS_KEY_USER];

            if (mUser == null)
            {
                getUserFromCookie();
                if (mUser == null)
                {
                    Response.Redirect("login.aspx");
                    Response.Close();
                    return;
                }
            }
            PilotClassID = Request.Params["PilotClassID"];
            achievedWhen = PilotClass.WhenAchieved(Guid.Parse(PilotClassID), mUser.UserEmail);
            pcd          = PilotClassDefinition.getPilotClassDefinition(Guid.Parse(PilotClassID));
            IEnumerable <PilotClassPrereq> prereqs = PilotClassPrereq.getPrereqs(Guid.Parse(PilotClassID));

            requirements = new List <AchievementDefinition>();
            if (prereqs != null && prereqs.Count <PilotClassPrereq>() >= 0)
            {
                foreach (PilotClassPrereq pcp in prereqs)
                {
                    AchievementDefinition ad = AchievementDefinition.getAchievementDefinition(pcp.AchievementID);
                    requirements.Add(ad);
                }
            }

            // now we have the list of requirements too.
        }
Exemple #2
0
        public void ProcessRequest(HttpContext context)
        {
            Dictionary <String, object> res         = new Dictionary <string, object>();
            List <Object> finalList                 = new List <object>();
            IEnumerable <PilotClassDefinition> achs = PilotClassDefinition.getAll();

            foreach (PilotClassDefinition r in achs)
            {
                IEnumerable <PilotClassPrereq> pre = PilotClassPrereq.getPrereqs(r.PilotClassID);

                Dictionary <string, string> obj = new Dictionary <string, string>();
                obj.Add("PilotClass", r.PilotClassName);
                obj.Add("PilotLogo", r.Logo);
                obj.Add("Prerequisites", pre.Count <PilotClassPrereq>().ToString());
                obj.Add("actions", r.PilotClassID.ToString());
                obj.Add("PilotClassID", r.PilotClassID.ToString());
                obj.Add("PilotClassDescription", r.PilotClassDescription);

                finalList.Add(obj);
            }
            res.Add("data", finalList);
            string json = JsonConvert.SerializeObject(res);

            context.Response.Write(json);
        }