public async Task <IActionResult> Edit(string id, [Bind("EmployeeID,Name,OrgID,Phone,Mobile,Office")] Employee employee) { if (id != employee.EmployeeID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(employee); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!EmployeeExists(employee.EmployeeID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(employee)); }
public async Task <IActionResult> Edit(int id, [Bind("AddressID,PhoneNumber,Email,StreetName,HomeNumber,PostalCode,City,PersonID")] Address address) { if (id != address.AddressID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(address); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!AddressExists(address.AddressID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["PersonID"] = new SelectList(_context.Person, "PersonID", "FirstName", address.PersonID); return(View(address)); }
public async Task <IActionResult> Edit(int id, int OrgId, [Bind("Id,Name,PhoneNumber,Address")] Person person) { if (id != person.Id) { return(NotFound()); } person.OrganizationId = OrgId; if (ModelState.IsValid) { try { _context.Update(person); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PersonExists(person.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction("Details", "Organizations", new{ id = OrgId })); } return(View(person)); }
public async Task <IActionResult> Edit(int id, [Bind("Id,Name,Address,PhoneNumber")] Organization organization) { if (id != organization.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(organization); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!OrganizationExists(organization.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction("Index", "Organizations")); } return(View(organization)); }
public async Task <IActionResult> Edit(int id, [Bind("PersonID,FirstName,LastName")] Person person) { if (id != person.PersonID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(person); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PersonExists(person.PersonID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(person)); }
public async Task <IActionResult> Edit(int id, [Bind("Id,FirstName,LastName,Email,Avatar,FileName,Adress1,Address2,City,ZipCode,Phone,DateAdded")] AddressBookEntry addressBookEntry) { if (id != addressBookEntry.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(addressBookEntry); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!AddressBookEntryExists(addressBookEntry.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(addressBookEntry)); }
public async Task <IActionResult> Edit(int id, [Bind("Id,FirstName,LastName,Email,Avatar,Address1,Address2,City,State,ZipCode,Phone,DateAdded")] Address address, IFormFile avatar) { if (id != address.Id) { return(NotFound()); } if (ModelState.IsValid) { try { if (avatar != null) { address.Avatar = AvatarHelper.PutImage(avatar); address.FileName = avatar.FileName; } _context.Update(address); if (avatar == null) { _context.Entry(address).Property(p => p.Avatar).IsModified = false; } await _context.SaveChangesAsync(); _context.Update(address); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!AddressExists(address.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(address)); }
public bool EditContact(Contact contact) { try { _context.Update(contact); _context.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!ContactExists(contact.Id)) { return(false); } else { throw; } } return(true); }
public void EditPerson(Person person) { _context.Update(person); _context.SaveChanges(); }