public async Task <CustomerModel> Handle(UpdateCustomerCommand request, CancellationToken cancellationToken)
        {
            var entity = await _context.Customers
                         .SingleAsync(c => c.CustomerId == request.Id, cancellationToken);

            if (entity == null)
            {
                throw new NotFoundException(nameof(Customer), request.Id);
            }

            entity.Title          = request.Title;
            entity.FirstName      = request.FirstName;
            entity.LastName       = request.Lastname;
            entity.Address        = request.Address;
            entity.City           = request.City;
            entity.Region         = request.Region;
            entity.PostalCode     = request.PostalCode;
            entity.Country        = request.Country;
            entity.Phone          = request.Phone;
            entity.AccountCreated = request.AccountCreated;
            entity.DateOfBirth    = request.DateOfBirth;

            await _context.SaveChangesAsync(cancellationToken);

            return(CustomerModel.Create(entity));
        }
        public async Task <Unit> Handle(DeleteCustomerCommand request, CancellationToken cancellationToken)
        {
            var entity = await _context.Customers
                         .FindAsync(request.Id);

            if (entity == null)
            {
                throw new DeleteFailureException(nameof(Customer), request.Id, "Sorry you cannot delete this customer!");
            }

            _context.Customers.Remove(entity);
            await _context.SaveChangesAsync(cancellationToken);

            return(Unit.Value);
        }
        public async Task <CustomerModel> Handle(CreateCustomerCommand request, CancellationToken cancellationToken)
        {
            var entity = new Customer
            {
                CustomerId     = request.Id,
                Title          = request.Title,
                FirstName      = request.FirstName,
                LastName       = request.LastName,
                Address        = request.Address,
                City           = request.City,
                Region         = request.Region,
                PostalCode     = request.PostalCode,
                Country        = request.Country,
                Phone          = request.Phone,
                AccountCreated = request.AccountCreated,
                DateOfBirth    = request.DateOfBirth.Date
            };

            _context.Customers.Add(entity);
            await _context.SaveChangesAsync(cancellationToken);

            return(CustomerModel.Create(entity));
        }