Пример #1
0
        public async Task <IActionResult> AddAddress(string accountNumber, string customerName)
        {
            var vm = customerService.AddAddress(accountNumber, customerName);

            ViewData["addressTypes"] = (await referenceDataService.GetAddressTypesAsync())
                                       .OrderBy(a => a.Name)
                                       .ToList()
                                       .ToSelectList(a => a.Name, a => a.Name);

            ViewData["countries"] = (await referenceDataService.GetCountriesAsync())
                                    .OrderBy(c => c.Name)
                                    .ToList()
                                    .ToSelectList(x => x.CountryRegionCode, x => x.Name);

            ViewData["statesProvinces"] = (await referenceDataService.GetStatesProvincesAsync("US"))
                                          .OrderBy(s => s.Name)
                                          .ToList()
                                          .ToSelectList(x => x.StateProvinceCode, x => x.Name);

            return(View("Address", vm));
        }
        public async Task <ActionResult> NewAddress(AddressViewModel address)
        {
            var response = await _customerService.AddAddress(address);

            if (HasErrorsInResponse(response))
            {
                TempData["Errors"] =
                    ModelState.Values.SelectMany(v => v.Errors.Select(e => e.ErrorMessage)).ToList();
            }

            return(RedirectToAction("AddressDelivery", "Order"));
        }
Пример #3
0
        public async Task <IActionResult> AddNewAddress(AddressViewModel addressViewModel)
        {
            if (!ModelState.IsValid)
            {
                return(PartialView("~/Views/Shared/Address/_AddressList", addressViewModel));
            }

            await _customerService.AddAddress(_mapper.Map <Address>(addressViewModel));

            if (!ValidOperation())
            {
                return(PartialView("~/Views/Shared/Address/_AddAddress", addressViewModel));
            }

            var url = Url.Action("GetAddressesCollaborator", "Customers", new { id = addressViewModel.CustomerId });

            return(Json(new { success = true, url }));
        }