示例#1
0
        public ActionResult Create(CustomerViewModel viewModel)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(View(viewModel));
                }

                var custom = new CustomerDTO
                {
                    CustomerFirstName = viewModel.CustomerFirstName,
                    CustomerLastName  = viewModel.CustomerLastName,
                    CompanyName       = viewModel.CompanyName,
                    CompanyAddress    = viewModel.CompanyAddress,
                    CustomerDescript  = viewModel.CustomerDescript
                };

                customService.AddCustom(custom);

                return(RedirectToAction("Index"));
            }
            catch (Exception e)
            {
                ModelState.AddModelError("", e.Message);
            }
            return(View(viewModel));
        }