コード例 #1
0
        public async Task <bool> UpdateUserCardGranted(UserCardGranted userCardGranted)
        {
            var existingUserCardGranted = await _unitOfWork.UserCardGrantedRepository.GetById(userCardGranted.Id);

            existingUserCardGranted.id_card = userCardGranted.id_card;
            existingUserCardGranted.id_user = userCardGranted.id_user;
            _unitOfWork.UserCardGrantedRepository.Update(existingUserCardGranted);
            await _unitOfWork.SaveChangesAsync();

            return(true);
        }
コード例 #2
0
        public async Task InsertUserCardGranted(UserCardGranted userCardGranted)
        {
            if (await _unitOfWork.UserRepository.GetById(userCardGranted.id_user) == null)
            {
                throw new BusinessException("User doesn't exist");
            }
            if (await _unitOfWork.CardsRepository.GetById(userCardGranted.id_card) == null)
            {
                throw new BusinessException("Card doesn't exist");
            }
            await _unitOfWork.UserCardGrantedRepository.Add(userCardGranted);

            await _unitOfWork.SaveChangesAsync();
        }