예제 #1
0
        public bool Delete(int id)
        {
            var post = _context.Posts.Where(p => p.Id == id).FirstOrDefault();

            if (post != null)
            {
                _context.Posts.Remove(post);
                _context.SaveChanges();
                return(true);
            }

            return(false);
        }
예제 #2
0
        public bool Delete(int id)
        {
            var user = _context.Users.Where(u => u.Id == id).FirstOrDefault();

            if (user != null)
            {
                _context.Users.Remove(user);
                _context.SaveChanges();
                return(true);
            }

            return(false);
        }
예제 #3
0
 public bool Insert(Tag tag)
 {
     if (_context.Tags.Where(t => t.Name.ToLowerInvariant().Equals(tag.Name)).Any())
     {
         return(false);
     }
     _context.Tags.Add(tag);
     _context.SaveChanges();
     return(true);
 }