public ActionResult EditContact(Contact editedContact) { DbConnection conn = new DbConnection(); conn.SqlCommand.Connection.Open(); ContactLogic contactlogic = new ContactLogic(); bool success = contactlogic.UpdateContact(conn, editedContact.Name, editedContact.Surname, editedContact.Phone, editedContact.Email, editedContact.Id); if (success) { ViewData["Message"] = ErrorMessages.EditContact_Success; } else { ViewData["Message"] = ErrorMessages.EditContact_Error; } conn.SqlCommand.Connection.Close(); return(View("Messages")); }
public async Task <IActionResult> PutContact(long id, Contact contact) { if (id != contact.Id) { return(BadRequest()); } try { int data = await _context.UpdateContact(id, contact); } catch (DbUpdateConcurrencyException) { if (!await _context.VerifyContact(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }