Beispiel #1
0
        public int DeleteUser(User user)
        {
            var simpleListRepository = new SimpleListRepository(_simpleListEntities);
            var simpleLists          = simpleListRepository.GetSimpleLists(user.ID);

            if (simpleLists.Count() > 0)
            {
                throw new NonEmptyEntityException(NonEmptyEntityException.GetExceptionMessage(typeof(User), typeof(SimpleList.DataModel.Models.SimpleListItem)));
            }
            _simpleListEntities.Users.Remove(user);
            return(_simpleListEntities.SaveChanges());
        }
        public int DeleteSimpleList(int userId, int simpleListId)
        {
            var simpleListItemRepository = new SimpleListItemRepository(_simpleListEntities);
            var simpleListItems          = simpleListItemRepository.GetSimpleListItems(userId, simpleListId);

            if (simpleListItems.Count() > 0)
            {
                throw new NonEmptyEntityException(NonEmptyEntityException.GetExceptionMessage(typeof(SimpleList.DataModel.Models.SimpleList), typeof(SimpleListItem)));
            }
            var simpleList = GetSimpleList(userId, simpleListId);

            _simpleListEntities.SimpleLists.Remove(simpleList);
            return(_simpleListEntities.SaveChanges());
        }