예제 #1
0
        public bool DeleteExample(int id)
        {
            using (var context = new ApplicationDbContext())
            {
                var entity = context.CodeExamples.Single(j => j.CodeExampleId == id);
                if (entity == null)
                {
                    return(false);
                }
                var service = new OnDelete();

                context.CodeExamples.Remove(entity);

                return(context.SaveChanges() == 1);
            }
        }
예제 #2
0
        public bool DeleteCategory(int id)
        {
            using (var context = new ApplicationDbContext())
            {
                var content = context.Categories.Find(id);
                var service = new OnDelete();

                try
                {
                    service.OnDeleteCategory(id);
                    context.Categories.Remove(content);
                    context.SaveChanges();
                    return(true);
                }
                catch
                {
                    return(false);
                }
            }
        }