public async Task <IActionResult> Edit(string id, [Bind("Id,Name,Address,RefLeadId")] Company company) { if (id != company.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(company); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CompanyExists(company.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["RefLeadId"] = new SelectList(_context.Leads, "Id", "FullName", company.ContactId); return(View(company)); }
public async Task <IActionResult> Edit(string id, [Bind("Id,OwnerId,LeadId,ProductId,CreationDate,EstimatedCloseDate,Comments,Status,Confidence")] Opportunity opportunity) { if (id != opportunity.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(opportunity); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!OpportunityExists(opportunity.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["LeadId"] = new SelectList(_context.Leads, "Id", "FullName", opportunity.LeadId); ViewData["OwnerId"] = new SelectList(_context.Users, "Id", "UserName", opportunity.OwnerId); ViewData["ProductId"] = new SelectList(_context.Products, "Id", "Title", opportunity.ProductId); ViewData["Confidence"] = new SelectList(OpportunityConfidence.AllConfidenceDisplay, "Key", "Value", opportunity.Confidence); ViewData["Status"] = new SelectList(OpportunityStatus.AllStatusDisplay, "Key", "Value", opportunity.Status); return(View(opportunity)); }
public async Task <IActionResult> Edit(string id, [Bind("Id,Title,Description")] Product product) { if (id != product.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(product); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ProductExists(product.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(product)); }