Beispiel #1
0
        public Guid AddUserAnswer(UserAnswer userAnswer)
        {
            if (_dbContext.UserAnswer.Any(a => a.Id == userAnswer.Id))
            {
                throw new ArgumentException($"User id {userAnswer.Id} already exists");
            }

            userAnswer.UserSectors = GetUserNewSectors(userAnswer.Id, userAnswer.UserSectorCodes);

            _dbContext.UserAnswer.Add(userAnswer);
            _dbContext.SaveChanges();

            return(userAnswer.Id);
        }
Beispiel #2
0
        public bool DeleteClient(int id)
        {
            var clientFound = _context.Clients.Find(id);

            if (clientFound == null)
            {
                return(false);
            }

            _context.Clients.Remove(clientFound);
            var changes = _context.SaveChanges();

            if (changes == 0)
            {
                return(false);
            }

            return(true);
        }