예제 #1
0
        public virtual void Update(IStory theStory, string uniqueName, DateTime createdAt, string title, string category, string description, string tags)
        {
            Check.Argument.IsNotNull(theStory, "theStory");

            using (IUnitOfWork unitOfWork = UnitOfWork.Begin())
            {
                if (string.IsNullOrEmpty(uniqueName))
                {
                    uniqueName = theStory.UniqueName;
                }

                if (!createdAt.IsValid())
                {
                    createdAt = theStory.CreatedAt;
                }

                theStory.ChangeNameAndCreatedAt(uniqueName, createdAt);

                if (!string.IsNullOrEmpty(title))
                {
                    theStory.Title = title;
                }

                if ((!string.IsNullOrEmpty(category)) &&
                    (string.Compare(category, theStory.BelongsTo.UniqueName, StringComparison.OrdinalIgnoreCase) != 0))
                {
                    ICategory storyCategory = _categoryRepository.FindByUniqueName(category);
                    theStory.ChangeCategory(storyCategory);
                }

                if (!string.IsNullOrEmpty(description))
                {
                    theStory.HtmlDescription = description.Trim();
                }
                theStory.RemoveAllTags();
                AddTagsToContainers(tags, new[] { theStory });

                unitOfWork.Commit();
            }
        }