public void UpdateNewsEntry(NewsEntryContract contract) { ParamIs.NotNull(() => contract); PermissionContext.VerifyPermission(PermissionToken.EditNews); HandleTransaction(session => { var user = GetLoggedUser(session); if (contract.Id == 0) { var entry = new NewsEntry(contract.Text, user, contract.Anonymous, contract.Important, contract.Stickied); session.Save(entry); AuditLog("created " + entry, session, user); } else { var entry = session.Load<NewsEntry>(contract.Id); entry.Anonymous = contract.Anonymous; entry.Important = contract.Important; entry.Stickied = contract.Stickied; entry.Text = contract.Text; session.Update(entry); AuditLog("updated " + entry, session, user); } }); }
public NewsEntryEdit(NewsEntryContract contract) : this() { ParamIs.NotNull(() => contract); Anonymous = contract.Anonymous; CreateDate = contract.CreateDate; Id = contract.Id; Important = contract.Important; Stickied = contract.Stickied; Text = contract.Text; }