public async Task <IActionResult> Edit(int id, [Bind("TypesJobId,Name,LicenseId,ContractorId,Price")] TypesJob typesJob) { if (id != typesJob.TypesJobId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(typesJob); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TypesJobExists(typesJob.TypesJobId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["ContractorId"] = new SelectList(_context.Contractors, "ContractorId", "NameCompany", typesJob.ContractorId); ViewData["LicenseId"] = new SelectList(_context.Licenses, "LicenseId", "Number", typesJob.LicenseId); return(View(typesJob)); }
public async Task <IActionResult> Create([Bind("TypesJobId,Name,LicenseId,ContractorId,Price")] TypesJob typesJob) { if (ModelState.IsValid) { _context.Add(typesJob); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["ContractorId"] = new SelectList(_context.Contractors, "ContractorId", "NameCompany", typesJob.ContractorId); ViewData["LicenseId"] = new SelectList(_context.Licenses, "LicenseId", "Number", typesJob.LicenseId); return(View(typesJob)); }