Ejemplo n.º 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;
                }
            }
            RewardID     = Request.Params["RewardID"];
            achievedWhen = PilotClass.WhenAchieved(Guid.Parse(RewardID), mUser.UserEmail);
            rd           = RewardDefinition.getRewardDefinition(Guid.Parse(RewardID));
            IEnumerable <RewardPrereq> prereqs = RewardPrereq.getPrereqs(Guid.Parse(RewardID));

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

            // now we have the list of requirements too.
        }
Ejemplo n.º 2
0
        public void ProcessRequest(HttpContext context)
        {
            /*Dictionary<String, object> res = new Dictionary<string, object>();
             * List<Object> finalList = new List<object>();
             * IEnumerable<RewardDefinition> rews = RewardDefinition.getAll();
             * foreach (RewardDefinition r in rews)
             * {
             *  List<string> obj = new List<string>();
             *  obj.Add("");
             *  obj.Add(r.RewardName);
             *  obj.Add(r.RewardType);
             *  obj.Add(r.getRewardDetail());
             *  finalList.Add(obj);
             * }
             * res.Add("data", finalList);
             * string json = JsonConvert.SerializeObject(res);
             * context.Response.Write(json);
             */
            Dictionary <String, object> res     = new Dictionary <string, object>();
            List <Object> finalList             = new List <object>();
            IEnumerable <RewardDefinition> rews = RewardDefinition.getAll();

            foreach (RewardDefinition r in rews)
            {
                Dictionary <string, string> obj = new Dictionary <string, string>();
                obj.Add("empty", "");
                obj.Add("Reward", r.RewardName);
                obj.Add("RewardLogo", r.Logo);
                obj.Add("Prerequisites", RewardPrereq.getPrereqs(r.RewardID).Count <RewardPrereq>().ToString());
                obj.Add("Type", r.RewardType);
                obj.Add("Detail", r.getRewardDetail());
                obj.Add("actions", r.RewardID.ToString());
                obj.Add("RewardID", r.RewardID.ToString());
                obj.Add("RewardItem", r.RewardItem);
                obj.Add("RewardCount", (r.RewardCount != null) ? r.RewardCount.ToString() : "");
                obj.Add("RewardDesc", (r.RewardDesc != null) ? r.RewardDesc:"");
                obj.Add("RewardValidity", (r.RewardValidityTill != null)?String.Format("{0:MM/dd/yyyy}", r.RewardValidityTill):"");

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

            context.Response.Write(json);
        }