Example #1
0
        public async Task <Response <UserDTO> > Get(Guid userId)
        {
            ISpecification <User> registeredSpec =
                new UserRegisteredSpec(userId);

            User user = await this.genericRepository.FindOneAsync(registeredSpec);

            return(new Response <UserDTO>(this.mapper.Map <User, UserDTO>(user)));
        }
Example #2
0
        public async Task Remove(Guid userId)
        {
            ISpecification <User> registeredSpec =
                new UserRegisteredSpec(userId);

            User user = await this.genericRepository.FindOneAsync(registeredSpec);

            if (user == null)
            {
                throw new ArgumentException("No such customer exists");
            }

            this.genericRepository.Delete(user);
            await this.unitOfWork.CommitAsync();
        }
Example #3
0
        public async Task Update(UserDTO userDto)
        {
            if (userDto.Id == Guid.Empty)
            {
                throw new ArgumentException("Id can't be empty");
            }

            ISpecification <User> registeredSpec =
                new UserRegisteredSpec(userDto.Id);

            User user = await this.genericRepository.FindOneAsync(registeredSpec);

            if (user == null)
            {
                throw new ArgumentException("No such user exists");
            }

            user.Update(userDto.Name, userDto.Email);
            await this.unitOfWork.CommitAsync();
        }