public ActionResult EditAccount(EditAccountModel model) { EventLogHandler Logger = new EventLogHandler(); var sessionUser = Session["Username"] as string; if (ModelState.IsValid) { List <ChartOfAcc> accountsList; List <string> AccountDetails = new List <string>(); List <string> NewAccountDetails = new List <string>(); using (IDbConnection db = new SqlConnection(SqlAccess.GetConnectionString())) { accountsList = db.Query <ChartOfAcc>($"Select * From dbo.ChartOfAccounts Where AccountNumber = @ID", new { ID = model.AccountNumber }).ToList(); } AccountDetails.Add("Name:" + accountsList[0].AccountName); AccountDetails.Add("Active: " + accountsList[0].Active); AccountDetails.Add("Type: " + accountsList[0].AccountType); AccountDetails.Add("Description:" + accountsList[0].AccountDescription); string DetailedFrom = String.Join("|^|", AccountDetails); using (IDbConnection db = new SqlConnection(SqlAccess.GetConnectionString())) { string sql = "Update dbo.ChartOfAccounts set AccountName = @AccountName, " + "AccountType = @AccountType, AccountDescription = @AccountDescription," + "Active = @Active Where AccountNumber = @AccountNumber"; db.Execute(sql, new { AccountNumber = model.AccountNumber, AccountName = model.AccountName, AccountType = model.AccountType, AccountDescription = model.AccountDescription, Active = model.Active }); } NewAccountDetails.Add("Name:" + model.AccountName); NewAccountDetails.Add("Active: " + model.Active); NewAccountDetails.Add("Type: " + model.AccountType); NewAccountDetails.Add("Description:" + model.AccountDescription); string DetailedTo = String.Join("|^|", NewAccountDetails); TempData["Message"] = "Your entry was successfully updated!"; Logger.LogAdminEditAccount(sessionUser, model.AccountName, DetailedFrom, DetailedTo); return(RedirectToAction("ChartOfAccounts")); } return(View(model)); }