コード例 #1
0
        public CustomerRegistrationResponseDto TryToRegister(CustomerRegistrationRequestDto dto)
        {            
            if(uow.Users.GetAll().Where(x=>x.Username == dto.Email).FirstOrDefault() != null)
                throw new System.Exception("Invalid Email Address");

            var user = new User()
            {
                Username = dto.Email,
                Firstname = dto.Firstname,
                Lastname = dto.Lastname,
                Password = encryptionService.TransformPassword(dto.Password),
            };
            
            var account = new Account()
            {
                Firstname = dto.Firstname,
                Lastname = dto.Lastname,
                Email = dto.Email,
                AccountType = AccountType.Customer,
                User = user,
                AccountStatus = AccountStatus.Free
            };

            var profile = new Profile()
            {
                Name = string.Format("{0} {1}",dto.Firstname, dto.Lastname),
                Account = account,
                ProfileType = ProfileType.Customer,
                IsPersonalized = true,
                IsApproved = true,                
            };

            var customer = new Customer()
            {
                Firstname = dto.Firstname,
                Lastname = dto.Lastname,
                Email = dto.Email,
                Profile = profile
            };
            
            user.Accounts.Add(account);
            account.Profiles.Add(profile);

            uow.Users.Add(user);
            uow.Accounts.Add(account);
            uow.Customers.Add(customer);
            uow.SaveChanges();

            var response = new CustomerRegistrationResponseDto()
            {
                Firstname = customer.Firstname,
                Lastname = customer.Lastname,
                Id = customer.Id
            };

            return response;
        }
コード例 #2
0
 public ProfileDto(Profile profile)
 {
     this.Id = profile.Id;
     this.Firstname = profile.Account.Firstname;
     this.Lastname = profile.Account.Lastname;
     this.Email = profile.Account.Email;
     this.Status = profile.Account.AccountStatus;
     this.IsApproved = profile.IsApproved;
     this.IsPersonalized = profile.IsPersonalized;
     this.ProfileType = profile.ProfileType;
 }