Пример #1
0
        public TagsResponse Edit(Tag tag)
        {
            var context = new PersonalBlogEntities();

            if (context.Tags.Contains(tag))
            {
                var response = new TagsResponse();
                response.Success = false;
                response.Message = $"The tag {tag} already exists in the database.";
                response.Tags.Add(tag);
                return(response);
            }
            else
            {
                return(repo.Edit(tag));
            }
        }
Пример #2
0
        public void Edit()
        {
            PostsRepo   postGet  = new PostsRepo();
            List <Post> junkPost = new List <Post>();

            junkPost.Add(postGet.GetAll().Posts.FirstOrDefault());
            Tag toAdd = new Tag {
                TagName = "#Testerized", Posts = junkPost
            };

            repo.Add(toAdd);

            Tag toEdit = repo.GetByName("#Testerized")
                         .Tags.First();

            toEdit.TagName = "#MrTsTea";
            TagsResponse response = repo.Edit(toEdit);

            Assert.AreEqual(true, response.Success);
        }