public async Task <IActionResult> NewRadarAsync(Radar radar) { //handling user-may-occur mistakes if (radar.system.StartsWith("Select") | radar.configuration.StartsWith("Select")) { ViewData["Message"] = "Please select System and Configuration"; return(View(radar)); } //If the radar name is null we give a default name that specifies its number and change when the location added String def_name; bool isNamed = false; if (String.IsNullOrEmpty(radar.name)) { int count = 0; try { count = await _session.GetRadarNumber(); } catch (Exception e) { // log exception here ViewData["Message"] = e.Message.ToString() + " Error"; await _session.Rollback(); return(View(radar)); } finally { _session.CloseTransaction(); } count = count + 1; def_name = "Radar " + count; isNamed = true; } else { def_name = radar.name; } //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 d = new Data(); Program.data.TryGetValue(sessionID, out d); d.Radar = new Radar(def_name, radar.system, radar.configuration); d.Radar.Isnamed = isNamed; return(RedirectToAction("NewLocation", "Location")); }