コード例 #1
0
        public ActionResult Copy(string id, string newId)
        {
            Signal newSignal = new Signal();

            if (id == null)
            {
                return(Content("<h1>A signal ID is required</h1>"));
            }
            Signal signal = _signalsRepository.GetLatestVersionOfSignalBySignalID(id);

            if (signal != null)
            {
                newSignal = Signal.CopySignal(signal, newId);
                newSignal.VersionActionId = 1;
                newSignal.Start           = DateTime.Now;
                newSignal.Note            = "Copy of Signal " + id;
                newSignal.VersionList     = new List <Signal> {
                    newSignal
                };
            }
            try
            {
                _signalsRepository.AddOrUpdate(newSignal);
            }
            catch (Exception ex)
            {
                return(Content("<h1>" + ex.Message + "</h1>"));
            }
            finally
            {
                AddSelectListsToViewBag(newSignal);
            }
            return(PartialView("Edit", newSignal));
        }