Example #1
0
		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);

				}

			});

		}
Example #2
0
        public NewsEntryContract(NewsEntry newsEntry)
        {
            ParamIs.NotNull(() => newsEntry);

            Anonymous = newsEntry.Anonymous;
            Author = new UserContract(newsEntry.Author);
            CreateDate = newsEntry.CreateDate;
            Id = newsEntry.Id;
            Important = newsEntry.Important;
            Stickied = newsEntry.Stickied;
            Text = newsEntry.Text;
        }