Пример #1
0
        public IActionResult ContactToAddressForm(CreateContactToAddressVM createContactToAddressVm)
        {
            if (!ModelState.IsValid)
            {
                return(View(createContactToAddressVm));
            }

            SQLRepository.CreateContactToAddress(createContactToAddressVm.SelectedContactValue, createContactToAddressVm.SelectedAddressValue);
            return(RedirectToAction(nameof(Index)));
        }
Пример #2
0
        public IActionResult ContactToAddressForm()
        {
            CreateContactToAddressVM createContactToAddressVm = new CreateContactToAddressVM
            {
                ContactItems = SQLRepository.ReadAllContacts()?
                               .Select(c => new SelectListItem
                {
                    Value = c.ID.ToString(),
                    Text  = $"{c.FirstName} {c.LastName}"
                }).ToArray(),
                AddressItems = SQLRepository.ReadAllAddresses()?
                               .Select(a => new SelectListItem
                {
                    Value = a.ID.ToString(),
                    Text  = $"{a.City}, {a.Street}"
                }).ToArray(),
            };

            return(View(createContactToAddressVm));
        }