Beispiel #1
0
        public async Task <RedirectToActionResult> DeleteSubmode(Guid id)
        {
            //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);
            if (current != null)
            {
                Mode m = current.LastMode.Mode;
                try
                {
                    _session.BeginTransaction();
                    Guid scan_id = await _session.GetScanID(id);

                    await _session.DeleteAntennaScanUsingScanID(scan_id);

                    await _session.DeleteScan(scan_id);

                    await _session.DeleteSubMode(id);

                    await _session.Commit();

                    current.message = "Submode " + id + "removed from database";
                }
                catch (Exception e)
                {
                    // log exception here
                    current.message = e.Message.ToString() + " Error";
                    await _session.Rollback();
                }
                finally
                {
                    _session.CloseTransaction();
                }

                return(RedirectToAction("BeforeEdit", "Mode", new { id = m.ID }));
            }
            return(RedirectToAction("RadarList", "AdminRadarList"));
        }