public IActionResult Delete(int id)
        {
            UserEntity userDb = _userRepository.GetSingle(id);

            if (userDb == null)
            {
                return(new NotFoundResult());
            }
            else
            {
                IEnumerable <Model.Entities.Fraction> existingFraction = _fractionRepository.FindBy(uh => uh.User.Id == id);
                if (existingFraction != null)
                {
                    throw new Exception("Cannot delete user because it has fractions tied to it!");
                }
                IEnumerable <Recycling.Model.Entities.UserHub> userHubs = _userHubRepository.FindBy(a => a.UserId == id);

                foreach (var userHub in userHubs)
                {
                    _userHubRepository.Delete(userHub);
                }

                _userRepository.Delete(userDb);

                _userRepository.Commit();

                return(new NoContentResult());
            }
        }
Beispiel #2
0
        public IActionResult Delete(int id)
        {
            UserHubEntity userHubEntity = _userHubRepository.GetSingle(id);

            if (userHubEntity == null)
            {
                return(new NotFoundResult());
            }
            else
            {
                _userHubRepository.Delete(userHubEntity);

                _userHubRepository.Commit();

                return(new NoContentResult());
            }
        }