コード例 #1
0
        public ActionResult Purchase(MailContext c)
        {
            try
            {
                List <BasketEntry> entries = Session["basket"] as List <BasketEntry>;

                if (entries == null)
                {
                    throw new Exception("Session has expired");
                }
                else if (entries.Count() == 0)
                {
                    throw new Exception("No items in the basket were found");
                }

                c.Entries = entries;

                List <IBuilder <string, MailContext> > builders = new List <IBuilder <string, MailContext> >()
                {
                    new MailHeaderBuilder()
                    {
                        Context = c
                    },
                    new MailBodyBuilder()
                    {
                        Context = c
                    },
                    new MailFooterBuilder()
                    {
                        Context = c
                    }
                };

                IDirector <string, MailContext> director = new MailDirector(builders);

                director.Act();

                Session["basket"] = null;

                return(new HttpStatusCodeResult(HttpStatusCode.OK));
            }
            catch (Exception e)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.InternalServerError, e.Message));
            }
        }
コード例 #2
0
ファイル: MailReadPatch.cs プロジェクト: veesusmikelheir/SRML
 public static void Postfix(MailDirector __instance, MailDirector.Mail mail)
 {
     MailRegistry.ModdedMails.FirstOrDefault((x) => mail.key == x.MailKey)?.onReadCallback(__instance, mail);
 }
コード例 #3
0
 /// <summary>The method called when this email is read</summary>
 protected virtual void OnReadMail(MailDirector dir, MailDirector.Mail mail)
 {
 }