Esempio n. 1
0
        public ActionResult SaveEmail()
        {
            try {
                if (Web.Session["Player"] == null)
                {
                    throw new Exception();
                }

                var player = UserSession.LoadPlayer();

                var isWinner = Request["isWinner"] == "true";
                var email    = Request["email"];

                if (isWinner)
                {
                    var prizeTypeID = Prize.LoadByWinnerPlayerID(player.PlayerID).PrizeTypeID;

                    var tb          = TextBlockCache.Get("WinningEmail", FileSystem.ReadTextFile("~/SiteCustom/email.html"), "Steps to claim your prize");
                    var description = "";

                    if (prizeTypeID == 3)                      // Limited Edition Cider Glasses
                    {
                        description = "Wild Side glasses don’t grow on trees. They’re found underground. And with the help of the farm dog, you dug one up. If you think it looks good now, wait until you pour cider into it - it’ll still look good. All you have to do is reply to this email and let us know what address to send it to. ";
                    }
                    else if (prizeTypeID == 4)                        // $100 Restaurant Voucher
                    {
                        description = "You found a $100 restaurant voucher - possibly the most delicious thing ever to grow in paddock soil. Please reply with your postal address so we can get your prize out to you. ";
                    }
                    else if (prizeTypeID == 5)                        // Wild Side Bottle Opener
                    {
                        description = "You just found a bottle opener in the Paddock of Prizes. Of course, you did have the help of master digger, sheep enthusiast, and current world fetch champion, the farm dog. Please reply to with your postal address so we can get your prize out to you.";
                    }

                    SendEMail.SimpleSendHTMLEmail(email, tb.Title, tb.BodyTextHtml.Replace("[firstname]", player.FirstName).Replace("[description]", description));
                }

                player.Email         = email;
                player.EmailSentDate = DateTime.Now;
                player.Save();
                Web.Session["Player"] = player;
                return(Content("OK"));
            }
            catch { }

            return(Content("ERROR"));
        }