Esempio n. 1
0
        public void GetByName(string name, int expected, bool valid)
        {
            TagsResponse response = repo.GetByName(name);

            Assert.AreEqual(valid, response.Success);
            if (valid == true)
            {
                Tag actual = response.Tags.First();
                Assert.AreEqual(expected, actual.TagId);
            }
        }
Esempio n. 2
0
        public TagsResponse GetByName(string tag)
        {
            var context = new PersonalBlogEntities();

            if (string.IsNullOrEmpty(tag))
            {
                return(repo.GetByName(tag));
            }

            if (context.Tags.FirstOrDefault(p => p.TagName == tag) == null)
            {
                var response = new TagsResponse();
                response.Success = false;
                response.Message = $"There are no posts with the tag {tag}.";
                return(response);
            }
            else
            {
                return(repo.GetByName(tag));
            }
        }