예제 #1
0
 public CustomerDTO FillDTO(AddCustomerVM customer)
 {
     return(new CustomerDTO
     {
         FirstName = customer.FirstName,
         LastName = customer.LastName,
         AddressAddressLine1 = customer.Address.AddressLine1,
         AddressAddressLine2 = customer.Address.AddressLine2,
         AddressCity = customer.Address.City,
         AddressZipCode = customer.Address.ZipCode,
         Company = customer.Company,
         CountryCountryName = customer.Country.CountryName,
         CountryId = customer.Country.Id
     });
 }
        public ActionResult Create(AddCustomerVM customer)
        {
            try
            {
                if (!customer.IsValid())
                {
                    //todo: create custom exceptions
                    return new JsonResult() { };
                }

                var customerDTO = customer.FillDTO(customer);

                // call application service
                _customerAppService.AddNewCustomer(customerDTO);

                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }
 public CustomerDTO FillDTO(AddCustomerVM customer)
 {
     return new CustomerDTO
         {
             FirstName = customer.FirstName,
             LastName = customer.LastName,
             AddressAddressLine1 = customer.Address.AddressLine1,
             AddressAddressLine2 = customer.Address.AddressLine2,
             AddressCity = customer.Address.City,
             AddressZipCode = customer.Address.ZipCode,
             Company = customer.Company,
             CountryCountryName = customer.Country.CountryName,
             CountryId = customer.Country.Id
         };
 }