public async Task <IActionResult> Edit(Location newValues) { //get session id (we will use it when updating data and handling errors) String sessionID_s = HttpContext.Session.GetString("Session"); Guid sessionID = Guid.Parse(sessionID_s); Data current = new Data(); Program.data.TryGetValue(sessionID, out current); current.Location = newValues; try { await _session.EditLocation(newValues); } catch (Exception e) { // log exception here ViewData["message"] = e.Message.ToString() + " Error"; await _session.Rollback(); return(RedirectToAction("BeforeEdit", "Location")); } finally { _session.CloseTransaction(); } current.edited = true; return(RedirectToAction("BeforeEdit", "Location")); }