public async Task <IActionResult> Edit(int id, [Bind("Id,Number,TypePhoneId,ContactId")] Phone phone) { if (id != phone.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(phone); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PhoneExists(phone.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction("Details", "Contact", new { id = phone.ContactId })); } ViewData["ContactId"] = new SelectList(_context.Contacts, "Id", "Name", phone.ContactId); ViewData["TypePhoneId"] = new SelectList(_context.TypePhones, "Id", "Name", phone.TypePhoneId); return(PartialView(phone)); }
public async Task <IActionResult> Edit(int id, [Bind("Id,Surname,Name,Patronymic,Address,Job,Position,Email,Skype,UserId,GroupId")] Contact contact) { if (id != contact.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(contact); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ContactExists(contact.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction("Index", "Home")); } ViewData["ContactId"] = id; ViewData["GroupId"] = new SelectList(_context.Groups, "Id", "Name", contact.GroupId); return(View(contact)); }
public ActionResult UpdateSave(string id, string surname, string telephone) { phoneBookContext = new PhoneBookContext(); phoneBookContext.Update(Guid.Parse(id), surname, telephone); ViewBag.PhoneBooks = phoneBookContext.PhoneBooks; return(View("Index")); }
public async Task <IActionResult> Edit(int id, [Bind("ContactId,Email,FirstName,LastName,Phone")] Contacts contacts) { if (id != contacts.ContactId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(contacts); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ContactsExists(contacts.ContactId)) { return(NotFound()); } else { throw; } } return(RedirectToAction("Index")); } return(View(contacts)); }
public async Task <IActionResult> Edit(int id, [Bind("ClienteId,Nome,Cpf,Cpnj,Email,TelefoneCelular,TelefoneResidencial,TelefoneComercial,Endereco")] Clientes clientes) { if (id != clientes.ClienteId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(clientes); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ClientesExists(clientes.ClienteId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(clientes)); }
public async Task <IActionResult> Edit(long id, [Bind("Id,Type,FirstName,LastName,Image,Address,Description")] Person person) { if (id != person.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(person); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PersonExists(person.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(person)); }
public async Task <IActionResult> Edit(long id, [Bind("Id,Type,Number,PersonId")] Phone phone) { if (id != phone.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(phone); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PhoneExists(phone.Id)) { return(NotFound()); } else { throw; } } return(new RedirectToActionResult(nameof(Index), "Phones", new { pid = phone.PersonId })); } ViewData["PersonId"] = phone.PersonId; return(View(phone)); }
public ActionResult UpdateSave(string id, string surname, string telephone) { phoneBookContext = new PhoneBookContext(Server.MapPath("~/Models/Data.json")); phoneBookContext.Update(Guid.Parse(id), surname, telephone); ViewBag.PhoneBooks = phoneBookContext.PhoneBooks; return(View("Index")); }
public IActionResult Update(DTO.Person person) { using (var context = new PhoneBookContext()) { var modelPerson = _mapper.Map <Person>(person); if (modelPerson != null) { context.Update(modelPerson); context.SaveChanges(); return(Ok()); } } return(NotFound()); }
public async Task <IActionResult> Edit(int id, [Bind("Id,Name")] Group @group) { var name = User.Identity.Name; User user = _context.Users.FirstOrDefault(u => u.UserName == name); if (user != null) { ViewData["NameUser"] = user.Surname + " " + user.Name; } if (id != @group.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(@group); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!GroupExists(@group.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(@group)); }