public IActionResult Create(CreateClientViewModel model) { if (ModelState.IsValid) { Passport pass = new Passport() { passport1 = model.passport1, passport2 = model.passport2, passport3 = model.passport3, date1 = model.date1, date2 = model.date2, authority = model.authority, sex = model.sex, date3 = model.date3, surname = model.surname, name = model.name, patronymic = model.patronymic, }; int idpass = _context.AddPassport(pass); Address address = new Address() { country = model.country, type1 = model.type1, city = model.city, type2 = model.type2, street = model.street, numhouse = Convert.ToInt32(model.numhouse), numapartment = Convert.ToInt32(model.numapartment), index = model.index, housephone = model.housephone, mobilephone = model.mobilephone, email = model.email, }; int id_addr = _context.AddAddress(address); Client client = new Client() { id_passport = idpass, id_address = id_addr, }; int id_cl = _context.AddClient(client); if (id_cl != 0) { User user = _context.FindUser(User.Identity.Name); user.id_client = id_cl; _context.UpdateUser(user.Id, user); return(RedirectToAction("Index", "Home")); } else { ModelState.AddModelError("", "Ошибка"); } } return(View(model)); }