Example #1
0
        private static void VoteForPizza()
        {
            PostParams = WebUtil.RetrievePostParameters();

            var pizza = DataBridge.GetPizzaById(int.Parse(PostParams["pizzaid"]));

            var vote = PostParams["pizzaVote"];

            if (vote == "up")
            {
                pizza.UpVotes++;
            }
            else if (vote == "down")
            {
                pizza.DownVotes++;
            }

            DataBridge.SaveChanges();
        }
Example #2
0
        private static void LogIn()
        {
            RequestParameters = WebUtil.RetrievePostParameters();
            string email          = RequestParameters["email"];
            string password       = RequestParameters["password"];
            string hashedPassword = PasswordHeader.Hash(RequestParameters["password"]);
            var    user           = DataBridge.LogInUser(email, password);

            if (user != null)
            {
                var session = new Session()
                {
                    Id   = new Random().Next().ToString(),
                    User = user
                };

                Header.AddCookie(new Cookie("sid", session.Id));
                DataBridge.AddSession(session);
                DataBridge.SaveChanges();
            }
        }