示例#1
0
        public ActionResult Create(string id)
        {
            var existingSignal = signalsRepository.GetSignalBySignalID(id);

            if (existingSignal == null)
            {
                Signal signal = CreateNewSignal(id);
                try
                {
                    signalsRepository.AddOrUpdate(signal);
                }
                catch (Exception ex)
                {
                    return(Content("<h1>" + ex.Message + "</h1>"));
                }
                finally
                {
                    AddSelectListsToViewBag(signal);
                }
                return(PartialView("Edit", signal));
            }
            else
            {
                return(Content("<h1>Signal Already Exists</h1>"));
            }
        }
示例#2
0
        public ActionResult Edit(Signal signal)
        {
            try
            {
                ModelState.Clear();
                signal = SetDetectionTypes(signal);

                //var modelStateErrors = this.ModelState.Keys.SelectMany(key => this.ModelState[key].Errors);

                if (TryValidateModel(signal))
                {
                    MOE.Common.Models.Repositories.ISignalsRepository repository =
                        MOE.Common.Models.Repositories.SignalsRepositoryFactory.Create();
                    repository.AddOrUpdate(signal);
                    AddSelectListsToViewBag(signal);
                    return(Content("Save Successful!" + DateTime.Now.ToString()));
                }
                return(Content("There was a validation error."));
            }

            catch (ValidationException ex)
            {
                return(Content(ex.Message));
            }

            catch (Exception ex)
            {
                return(Content(ex.Message));
            }
        }
示例#3
0
        public int AddNewVersion(string id)
        {
            var existingSignal = _signalsRepository.GetLatestVersionOfSignalBySignalID(id);
            //if (existingSignal == null)
            //{
            //    return Content("<h1>" +"No Signal Matches this SignalID" + "</h1>");
            //}

            Signal signal = _signalsRepository.CopySignalToNewVersion(existingSignal);

            signal.VersionList = _signalsRepository.GetAllVersionsOfSignalBySignalID(signal.SignalID);

            try
            {
                _signalsRepository.AddOrUpdate(signal);
                var commentRepository = MOE.Common.Models.Repositories.MetricCommentRepositoryFactory.Create();
                foreach (var origVersionComment in existingSignal.Comments)
                {
                    MetricComment metricComment = new MetricComment
                    {
                        CommentText = origVersionComment.CommentText,
                        VersionID   = signal.VersionID,
                        SignalID    = existingSignal.SignalID,
                        TimeStamp   = origVersionComment.TimeStamp,
                    };
                    if (origVersionComment.MetricTypes != null)
                    {
                        metricComment.MetricTypeIDs = new List <int>();
                        foreach (var metricType in origVersionComment.MetricTypes)
                        {
                            metricComment.MetricTypeIDs.Add(metricType.MetricID);
                        }
                    }
                    commentRepository.AddOrUpdate(metricComment);
                }
            }
            catch (Exception ex)
            {
                return(-1);
            }
            finally
            {
                AddSelectListsToViewBag(signal);
            }
            return(signal.VersionID);
        }
示例#4
0
 public ActionResult Edit(Signal signal)
 {
     try
     {
         ModelState.Clear();
         signal = SetDetectionTypes(signal);
         if (TryValidateModel(signal))
         {
             MOE.Common.Models.Repositories.ISignalsRepository repository =
                 MOE.Common.Models.Repositories.SignalsRepositoryFactory.Create();
             repository.AddOrUpdate(signal);
         }
         AddSelectListsToViewBag(signal);
         return(Content("Save Successful!" + DateTime.Now.ToString()));
     }
     catch (Exception ex)
     {
         return(Content(ex.Message));
     }
 }