public static MassMail OpenMail(Character character, long mailId) { // 0 1 2 3 4 5 6 7 8 9 var m = Db.Query().CommandText("update charactermessages set wasread=1 where mailid=@mailID and owner=@characterID; select mailid,sender,folder,type,creation,wasread,targets,owner,subject,body from charactermessages where mailid=@mailID and owner=@characterID") .SetParameter("@mailID", mailId) .SetParameter("@characterID", character.Id) .ExecuteSingleRow(); if (m == null) { return(null); } return(new MassMail { mailID = m.GetValue <long>(0), sender = Character.Get(m.GetValue <int>(1)), folder = (MailFolder)m.GetValue <int>(2), type = (MailType)m.GetValue <int>(3), creation = m.GetValue <DateTime>(4), wasRead = m.GetValue <bool>(5), targets = GenxyConverter.DeserializeObject <int[]>(m.GetValue <string>(6)).ToCharacter().ToArray(), owner = Character.Get(m.GetValue <int>(7)), subject = m.GetValue <string>(8), body = m.GetValue <string>(9) }); }
public static IEnumerable <MassMail> ListFolder(Character character, int folder) { // 0 1 2 3 4 5 6 7 8 var mails = Db.Query().CommandText("select mailid,sender,folder,type,creation,wasread,targets,owner,subject from charactermessages where folder=@folder and owner=@owner") .SetParameter("@folder", folder).SetParameter("@owner", character.Id) .Execute(); return(mails.Select(m => new MassMail { mailID = m.GetValue <long>(0), sender = Character.Get(m.GetValue <int>(1)), folder = (MailFolder)m.GetValue <int>(2), type = (MailType)m.GetValue <int>(3), creation = m.GetValue <DateTime>(4), wasRead = m.GetValue <bool>(5), targets = GenxyConverter.DeserializeObject <int[]>(m.GetValue <string>(6)).ToCharacter().ToArray(), owner = Character.Get(m.GetValue <int>(7)), subject = m.GetValue <string>(8) })); }