예제 #1
0
        private CustomerUserDTO Map(CustomerUser dbCustomer)
        {

            return dbCustomer != null ? new CustomerUserDTO()
            {
                Id = dbCustomer.Id,
                UserName = dbCustomer.UserName,
                Email = dbCustomer.Email,
                Orders = (from order in dbCustomer.Orders
                          select new OrderDTO()
                          {
                              Id = order.Id,
                              ServiceName = order.ServiceName,
                              OrderDate = order.OrderDate,
                              CompletionDate = order.CompletionDate,
                              Price = order.Price,
                              ServiceQuality = order.ServiceQuality,
                              IsApproved = order.IsApproved,
                              IsCompleted = order.IsCompleted
                          }).ToList(),
                UserAddresses = (from useraddress in dbCustomer.UserAddresses
                                 select new UserAddressDTO()
                                 {
                                     FirstName = useraddress.FirstName,
                                     LastName = useraddress.LastName,
                                     Phone = useraddress.Phone,
                                     AddressLine1 = useraddress.AddressLine1,
                                     AddressLine2 = useraddress.AddressLine2,
                                     City = useraddress.City,
                                     State = useraddress.State,
                                     Zipcode = useraddress.Zipcode

                                 }).ToList()
            } : null;
        }
예제 #2
0
 public void Register(RegisterCustomerBindingModel model)
 {
     var customer = new CustomerUser
     {
         UserName = model.Email,
         Email = model.Email,
         Orders = new List<Order>(),
         UserAddresses = new List<UserAddress>() { new UserAddress() {
                              FirstName = model.PrimaryAddress.FirstName,
                              LastName = model.PrimaryAddress.LastName,
                              Phone = model.PrimaryAddress.Phone,
                              AddressLine1 = model.PrimaryAddress.AddressLine1,
                              AddressLine2 = model.PrimaryAddress.AddressLine2,
                              City = model.PrimaryAddress.City,
                              State = model.PrimaryAddress.State,
                              Zipcode = model.PrimaryAddress.Zipcode
                          }
         }
     };
     _userManager.Create(customer, model.Password);
 }