Пример #1
0
        public IActionResult NewCustomer(CustomerNewViewModel viewModel)
        {
            if (ModelState.IsValid)
            {
                var customer = new Customer();
                customer.Givenname            = viewModel.Givenname;
                customer.Surname              = viewModel.Surname;
                customer.Gender               = viewModel.SelectedGender;
                customer.Telephonecountrycode = viewModel.Telephonecountrycode;
                customer.Telephonenumber      = viewModel.Telephonenumber;
                customer.Emailaddress         = viewModel.Emailaddress;
                customer.Streetaddress        = viewModel.Streetaddress;
                customer.Zipcode              = viewModel.Zipcode;
                customer.City        = viewModel.City;
                customer.CountryCode = viewModel.CountryCode;
                customer.Country     = viewModel.Country;


                _repository.SaveCustomer(customer);
                return(RedirectToAction("Index"));
            }

            viewModel.Genders = GetGenderListItems();
            return(View(viewModel));
        }
Пример #2
0
        public IActionResult NewCustomer()
        {
            var viewModel = new CustomerNewViewModel();

            viewModel.Genders = GetGenderListItems();

            return(View(viewModel));
        }