public async Task <IActionResult> Edit(int id, [Bind("Id,AffiliateContractId,ServiceId,Observation")] AffiliateContractServices affiliateContractServices) { if (id != affiliateContractServices.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(affiliateContractServices); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!AffiliateContractServicesExists(affiliateContractServices.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index), new { id = affiliateContractServices.AffiliateContractId })); } ViewData["AffiliateContractId"] = new SelectList(_context.AffiliateContracts, "Id", "Id", affiliateContractServices.AffiliateContractId); ViewData["ServiceId"] = new SelectList(_context.Services, "Id", "Code", affiliateContractServices.ServiceId); return(View(affiliateContractServices)); }
public async Task <IActionResult> Create([Bind("Id,AffiliateContractId,ServiceId,Observation")] AffiliateContractServices affiliateContractServices) { if (ModelState.IsValid) { //affiliateContractServices.AffiliateContract = _context.AffiliateContracts.Where(x => x.Id == affiliateContractServices.AffiliateContractId).First(); affiliateContractServices.Id = 0; _context.Add(affiliateContractServices); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index), new { id = affiliateContractServices.AffiliateContractId })); } ViewData["AffiliateContractId"] = new SelectList(_context.AffiliateContracts, "Id", "Id", affiliateContractServices.AffiliateContractId); ViewData["ServiceId"] = new SelectList(_context.Services, "Id", "Code", affiliateContractServices.ServiceId); return(View(affiliateContractServices)); }