Exemple #1
0
        public async Task <IActionResult> DeleteAddress(DeleteCustomerAddressViewModel viewModel)
        {
            if (ModelState.IsValid)
            {
                await customerViewModelService.DeleteAddress(
                    viewModel.AccountNumber,
                    viewModel.AddressType
                    );

                return(RedirectToAction("Detail", new { viewModel.AccountNumber }));
            }

            return(View(viewModel));
        }
        public IActionResult AddressDelete(string id, string customerId)
        {
            var customer = _customerService.GetCustomerById(customerId);

            if (customer == null)
            {
                throw new ArgumentException("No customer found with the specified id", "customerId");
            }

            var address = customer.Addresses.FirstOrDefault(a => a.Id == id);

            if (address == null)
            {
                //No customer found with the specified id
                return(Content("No customer found with the specified id"));
            }
            if (ModelState.IsValid)
            {
                _customerViewModelService.DeleteAddress(customer, address);
                return(new NullJsonResult());
            }
            return(ErrorForKendoGridJson(ModelState));
        }