Esempio n. 1
0
        public async Task <Guid> Handle(RegisterRedBetCustomerCommand request, CancellationToken cancellationToken)
        {
            var customer = new RedBetCustomer(request.FirstName, request.LastName, request.AddressStreet, request.AddressNumber, request.AddressZipCode, request.FavoriteFootballTeam);
            await _customerRepository.AddAsync(customer);

            return(customer.Id);
        }
Esempio n. 2
0
        private static BaseCustomerDto GetCustomer(Domain.Customer.Customer customer)
        {
            var address = customer.Address;

            var addressDto = new CustomerAddressDto
            {
                Street  = address.Street,
                City    = address.City,
                ZipCode = address.ZipCode,
                Number  = address.Number
            };

            return(customer switch
            {
                MrGreenCustomer mrGreenCustomer => new MrGreenCustomerDto
                {
                    Id = mrGreenCustomer.Id,
                    FirstName = mrGreenCustomer.FirstName,
                    LastName = mrGreenCustomer.LastName,
                    PersonalNumber = mrGreenCustomer.PersonalNumber,
                    Address = addressDto
                },
                RedBetCustomer redBetCustomer => new RedBetCustomerDto
                {
                    Id = redBetCustomer.Id,
                    FirstName = redBetCustomer.FirstName,
                    LastName = redBetCustomer.LastName,
                    FavoriteFootballTeam = redBetCustomer.FavoriteFootballClub,
                    Address = addressDto
                },
                _ => throw new InvalidOperationException("Customer Type is not supported")
            });
Esempio n. 3
0
        public async Task <Unit> Handle(RegisterRedBetCustomerCommand request, CancellationToken cancellationToken)
        {
            // Any other logic for RedBet Customer
            var address  = Address.Create(request.Street, request.Number, request.ZipCode, request.City);
            var customer = new RedBetCustomer(
                request.FirstName,
                request.LastName,
                request.FavoriteFootballClub,
                address);

            await _customerRepository.Register(customer);

            return(Unit.Value);
        }