public IActionResult Create(CreateSupplierViewModel model) { if (ModelState.IsValid) { var 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); int id_cl = _context.FindUser(User.Identity.Name).id_client.Value; Supplier supp = new Supplier() { firmname = model.firmname, id_address = id_addr, unn = model.unn, id_client = id_cl }; int id_supp = _context.AddSupplier(supp); if (id_supp != 0) { return(RedirectToAction("Index", "Home")); } else { ModelState.AddModelError("", "Ошибка"); } } return(View(model)); }