public async Task <RedirectToActionResult> DeleteRadar() { //get session id (we will use it when updating data and handling errors) sessionID_s = HttpContext.Session.GetString("Session"); sessionID = Guid.Parse(sessionID_s); Data current = new Data(); Program.data.TryGetValue(sessionID, out current); try { _session.BeginTransaction(); await _session.DeleteScan(current.Radar.ID); await _session.DeleteLocation(current.Location.ID); await _session.DeleteReceiver(current.Receiver.ID); await _session.DeleteTransmitter(current.Transmitter.ID); await _session.DeleteLocation(current.Location.ID); await _session.Commit(); current.message = "Radar " + current.Radar.ID + " removed From Database"; } catch (Exception e) { // log exception here current.message = e.Message.ToString() + " Error"; await _session.Rollback(); } finally { _session.CloseTransaction(); } return(RedirectToAction("RadarList", "AdminRadarList")); }