public async Task <IActionResult> Edit(SubModeInfo 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); //not necessary to edit current data bc in submode page we will retrieve all scan informations from db again try { await _session.EditScan(newValues.Scan); } catch (Exception e) { // log exception here if (current != null) { current.message = e.Message.ToString() + " Error"; } await _session.Rollback(); } finally { _session.CloseTransaction(); } if (current != null) { current.edited = true; } return(RedirectToAction("BeforeEdit", "Scan", new { id = newValues.Scan.ID })); }