public bool IsEmailAvailable(string email) { var alreadyRegisteredSpec = new CustomerAlreadyRegisteredSpec(email); var existingCustomer = _customerRepository.FindOne(alreadyRegisteredSpec); return(existingCustomer == null); }
/// <summary> /// Get customer by email and password /// </summary> /// <param name="email"></param> /// <param name="password"></param> /// <returns></returns> public CustomerDto GetCustomerByEmailAndPassword(string email, string password) { ISpecification <Customer> alreadyRegisteredSpec = new CustomerAlreadyRegisteredSpec(email); var customer = _customerRepository.FindSingleBySpec(alreadyRegisteredSpec); return(_mapper.Map <CustomerDto>(customer)); throw new NotImplementedException(); }
/// <summary> /// Determines whether [is email available] [the specified email]. /// </summary> /// <param name="email">The email.</param> /// <returns><c>true</c> if [is email available] [the specified email]; otherwise, <c>false</c>.</returns> public bool IsEmailAvailable(string email) { ISpecification <Customer> alreadyRegisteredSpec = new CustomerAlreadyRegisteredSpec(email); var existingCustomer = _customerRepository.FindSingleBySpec(alreadyRegisteredSpec); return(existingCustomer == null); }
public bool IsEmailAvailable(string email) { ISpecification <Customer> alreadyRegisteredSpec = new CustomerAlreadyRegisteredSpec(email); Customer existingCustomer = this.customerRepository.FindOne(alreadyRegisteredSpec); if (existingCustomer == null) { return(true); } return(false); }
public CustomerDto Add(CustomerDto customerDto) { var alreadyRegisteredSpec = new CustomerAlreadyRegisteredSpec(customerDto.Email); var existingCustomer = _customerRepository.FindOne(alreadyRegisteredSpec); if (existingCustomer != null) { throw new Exception("Customer with this email already exists"); } var country = _countryRepository.FindById(customerDto.CountryId); var customer = Customer.Create(customerDto.FirstName, customerDto.LastName, customerDto.Email, country); _customerRepository.Add(customer); _unitOfWork.Commit(); return(_mapper.Map <Customer, CustomerDto>(customer)); }
public CustomerDto Add(CustomerDto customerDto) { ISpecification<Customer> alreadyRegisteredSpec = new CustomerAlreadyRegisteredSpec(customerDto.Email); Customer existingCustomer = this.customerRepository.FindOne(alreadyRegisteredSpec); if (existingCustomer != null) throw new Exception("Customer with this email already exists"); Country country = this.countryRepository.FindById(customerDto.CountryId); Customer customer = Customer.Create(customerDto.FirstName, customerDto.LastName, customerDto.Email, country); this.customerRepository.Add(customer); this.unitOfWork.Commit(); return AutoMapper.Mapper.Map<Customer, CustomerDto>(customer); }
public CustomerDto Add(CustomerDto customerDto) { ISpecification <Customer> alreadyRegisteredSpec = new CustomerAlreadyRegisteredSpec(customerDto.Email); Customer existingCustomer = this.customerRepository.FindOne(alreadyRegisteredSpec); if (existingCustomer != null) { throw new Exception("Customer with this email already exists"); } Country country = this.countryRepository.FindById(customerDto.CountryId); Customer customer = Customer.Create(customerDto.FirstName, customerDto.LastName, customerDto.Email, country); this.customerRepository.Add(customer); this.unitOfWork.Commit(); return(AutoMapper.Mapper.Map <Customer, CustomerDto>(customer)); }
public async Task<ResultModel<CustomerDto>> Handle(Command request, CancellationToken cancellationToken) { var alreadyRegisteredSpec = new CustomerAlreadyRegisteredSpec(request.Model.Email); var existingCustomer = await _customerRepository.FindOneAsync(alreadyRegisteredSpec); if (existingCustomer != null) { throw new Exception("Customer with this email already exists"); } // check country is exists and valid var (countryDto, isError, _) = await _countryApi.GetCountryByIdAsync(request.Model.CountryId); if (isError || countryDto.Id.Equals(Guid.Empty)) { throw new Exception("Country Id is not valid."); } var customer = Customer.Create(request.Model.FirstName, request.Model.LastName, request.Model.Email, request.Model.CountryId); //customer.AddDomainEvent(new CustomerCreatedIntegrationEvent()); var created = await _customerRepository.AddAsync(customer); return ResultModel<CustomerDto>.Create(new CustomerDto { Id = created.Id, FirstName = created.FirstName, LastName = created.LastName, Email = created.Email, CountryId = created.CountryId, Balance = created.Balance, Created = created.Created, Updated = created.Updated }); }
public bool IsEmailAvailable(string email) { ISpecification<Customer> alreadyRegisteredSpec = new CustomerAlreadyRegisteredSpec(email); Customer existingCustomer = this.customerRepository.FindOne(alreadyRegisteredSpec); if (existingCustomer == null) return true; return false; }