private static void AssertSetting(BlogSetting setting) { if (setting == null) { throw new BlogCore.Core.ValidationException("BlogSetting could not be null or empty."); } if (setting.PostsPerPage <= 0 || setting.PostsPerPage >= 20) { throw new BlogCore.Core.ValidationException("PostsPerPage in BlogSetting could not be less than zero and greater than 20 posts."); } if (setting.DaysToComment <= 0 || setting.DaysToComment >= 10) { throw new BlogCore.Core.ValidationException("PostsPerPage in BlogSetting could not be less than zero and greater than 10 days."); } }
public Blog ChangeSetting(BlogSetting setting) { Guid oldBlogSettingId; if (BlogSetting != null) { oldBlogSettingId = BlogSetting.BlogSettingId; } AssertSetting(setting); BlogSetting = setting; if (BlogSetting != null && Guid.Empty != oldBlogSettingId) { Events.Add(new BlogSettingChanged(oldBlogSettingId)); } return(this); }