public ActionResult Delete(ClientViewModel clientViewModel) { try { if (ModelState.IsValid) { clientViewModel.DeleteClient(clientViewModel); return(RedirectToAction("Index", "Client")); } return(RedirectToAction("Index", "Client")); } catch (DbUpdateException exception) { //Log Exception errorlogviewmodel = new ErrorLogViewModel(); errorlogviewmodel.LogError(exception); //Check for Referential Integrity if (((System.Data.SqlClient.SqlException)exception.InnerException.InnerException).Number == 547) { return(View("Error_ReferentialIntegrity")); } return(View("Error")); } catch (Exception ex) { errorlogviewmodel = new ErrorLogViewModel(); errorlogviewmodel.LogError(ex); return(View("Error")); } }