コード例 #1
0
        public async Task <IActionResult> Edit(Transmitter transmitter_temp)
        {
            //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.Transmitter = transmitter_temp;
            try
            {
                await _session.EditTransmitter(transmitter_temp.ID, transmitter_temp.name, transmitter_temp.modulation_type, transmitter_temp.max_frequency, transmitter_temp.min_frequency, transmitter_temp.power);
            }
            catch (Exception e)
            {
                // log exception here
                ViewData["message"] = e.Message.ToString() + " Error";
                await _session.Rollback();

                return(RedirectToAction("BeforeEdit", "Transmitter"));
            }
            finally
            {
                _session.CloseTransaction();
            }
            current.edited = true;
            return(RedirectToAction("BeforeEdit", "Transmitter"));
        }