コード例 #1
0
ファイル: Reservation.cs プロジェクト: justunion/JXHotel
        /// <summary>
        /// 取消
        /// </summary>
        public void Cancel()
        {
            ReservationCanceledEvent evnt = new ReservationCanceledEvent(this);

            evnt.CustomerEmailAddress = this.Customer.Email;
            evnt.CanceledDate         = DateTime.Now;
            DomainEvent.Publish <ReservationCanceledEvent>(evnt);
        }
コード例 #2
0
 /// <summary>
 /// 处理给定的事件。
 /// </summary>
 /// <param name="evnt">需要处理的事件。</param>
 public void Handle(ReservationCanceledEvent evnt)
 {
     try
     {
         Reservation Reservation = evnt.Source as Reservation;
         // 此处仅为演示,所以邮件内容很简单。可以根据自己的实际情况做一些复杂的邮件功能,比如
         // 使用邮件模板或者邮件风格等。
         Utils.SendEmail(evnt.CustomerEmailAddress,
                         "您的预定已经取消",
                         string.Format("您的预定 {0} 已于 {1} 取消。有关订单的更多信息,请与系统管理员联系。",
                                       Reservation.Id.ToString().ToUpper(), evnt.CanceledDate));
     }
     catch (Exception ex)
     {
         // 如遇异常,直接记Log
         Utils.Log(ex);
     }
 }