示例#1
0
        public virtual Mail SendMail(string receiverName, String title, String detail, ISession session)
        {

            Player receiver = (from player in session.Linq<Player>()
                               where player.Username == receiverName
                               && player != this
                               select player).SingleOrDefault<Player>();

            if (receiver == null)
                throw new TribalWarsException("Người chơi không tồn tại");

            Mail mail = new Mail();
            mail.Detail = detail;
            mail.From = this;
            mail.ReceiverDelete = false;
            mail.SenderDelete = false;
            mail.Time = DateTime.Now;
            mail.Title = title;
            mail.To = receiver;
            mail.Unread = true;

            session.Save(mail);
            return mail;
        }
示例#2
0
        public virtual void DeleteMail(Mail mail, ISession session)
        {
            if (mail.From != this && mail.To != this)
                return;
            if (mail.To == this)
                mail.ReceiverDelete = true;
            else
                mail.SenderDelete = true;

            if (mail.SenderDelete && mail.ReceiverDelete)
                session.Delete(mail);
            else
                session.Update(mail);
        }