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)); } }
public static void Postfix(MailDirector __instance, MailDirector.Mail mail) { MailRegistry.ModdedMails.FirstOrDefault((x) => mail.key == x.MailKey)?.onReadCallback(__instance, mail); }
/// <summary>The method called when this email is read</summary> protected virtual void OnReadMail(MailDirector dir, MailDirector.Mail mail) { }