/// <summary> /// Update the comment, if authorized /// </summary> /// <param name="user">Editing user</param> /// <param name="text">The new text. If the text is unchanged, provide /// the original text. This lets you take whatever is in the user text box</param> /// <param name="image">New image to use (null if no change, don't need to reupload orig) </param> /// <param name="removeImage">Flag to indicate the image was removed, since null image is no-op</param> /// <param name="level"></param> public void Update(User user, string text, byte[] image, bool removeImage, CommentAccessLevel level) { AssertModifyAuthorization(user); if (removeImage) { Image = new byte[0]; } // Only update the image if there was one passed and there is // no instruction to remove it. If the image edit was a no-op, // it won't have been submitted and will be null, otherwise it's new if (image != null && !removeImage) { Image = image; } Text = text; LastEditorId = user.UserName; Modified = DateTime.Now; AccessLevel = level; AssociatedOrgId = GetAssociatedOrgId(user, level); _dao.Save(this); }
public static void Save(User user) { _userDao.Save(user, true); }