public ActionResult Edit(Guid?id) { var model = new EditModel() { ModalMode = Request.IsAjaxRequest() }; if (id.HasValue) { var metricType = GetMetricTypeById(id.Value); model.Id = metricType.Id; model.SystemName = metricType.SystemName; model.DisplayName = metricType.DisplayName; model.NoSignalColor = ColorStatusSelectorValue.FromColor(metricType.NoSignalColor); model.ActualTime = TimeSpanHelper.FromSeconds(metricType.ActualTimeSecs); model.ConditionRed = metricType.ConditionAlarm; model.ConditionYellow = metricType.ConditionWarning; model.ConditionGreen = metricType.ConditionSuccess; model.ElseColor = ColorStatusSelectorValue.FromColor(metricType.ConditionElseColor); } else { // значения по умолчанию model.NoSignalColor = new ColorStatusSelectorValue() { RedChecked = true }; model.ElseColor = new ColorStatusSelectorValue() { RedChecked = true }; } return(View(model)); }
/// <summary> /// Добавление новой подписки /// </summary> /// <param name="obj"></param> /// <param name="channel"></param> /// <param name="componentTypeId"></param> /// <param name="componentId"></param> /// <returns></returns> public ActionResult Add( Guid?userId, SubscriptionObject? @object, SubscriptionChannel?channel, Guid?componentTypeId, Guid?componentId) { if (@object == null) { throw new UserFriendlyException("Не указан тип добавляемой подписки"); } userId = userId ?? CurrentUser.Id; var model = new SubscriptionEditModel() { ModalMode = Request.IsAjaxRequest(), ReturnUrl = Url.Action("Index", new { userId = userId }), Id = null, Object = @object.Value, NotifyBetterStatus = false, UserId = userId, CanShowChannel = channel == null, CanShowComponentType = componentTypeId == null, CanShowComponent = componentId == null, Channel = channel ?? SubscriptionChannel.Email, IsEnabled = true, Color = ColorStatusSelectorValue.FromColor(ObjectColor.Gray), MinimumDuration = null, ResendTime = null, ComponentTypeId = componentTypeId, ComponentId = componentId }; return(View("Edit", model)); }
public void Load(Guid?id, Guid?componentId) { if (id.HasValue) { var test = GetUnitTest(id.Value); CheckName = test.DisplayName; ComponentId = test.ComponentId; Period = TimeSpan.FromSeconds(test.PeriodSeconds ?? 0); ActualTime = TimeSpanHelper.FromSeconds(test.ActualTimeSecs); NoSignalColor = ColorStatusSelectorValue.FromColor(test.NoSignalColor); ErrorColor = ColorStatusSelectorValue.FromUnitTestResultStatus(test.ErrorColor); if (ErrorColor.NotChecked) { ErrorColor.RedChecked = true; } } else { Period = TimeSpan.FromMinutes(10); ActualTime = TimeSpan.FromMinutes(20); ComponentId = componentId; CheckName = DefaultCheckName; ErrorColor = ColorStatusSelectorValue.FromUnitTestResultStatus(UnitTestResult.Alarm); NoSignalColor = ColorStatusSelectorValue.FromUnitTestResultStatus(UnitTestResult.Alarm); } }
public ActionResult Edit(Guid?id, Guid?componentId, Guid?metricTypeId) { var model = new EditModel() { ComponentId = componentId, MetricTypeId = metricTypeId }; if (id.HasValue) { var metric = GetMetricById(id.Value); if (metric != null) { model.Metric = metric; model.MetricType = metric.MetricType; model.Id = metric.Id; model.ComponentId = metric.ComponentId; model.MetricTypeId = metric.MetricTypeId; model.ConditionRed = metric.ConditionAlarm; model.ConditionYellow = metric.ConditionWarning; model.ConditionGreen = metric.ConditionSuccess; model.ElseColor = ColorStatusSelectorValue.FromColor(metric.ConditionElseColor); model.ActualTime = TimeSpanHelper.FromSeconds(metric.ActualTimeSecs); } } return(View(model)); }
public ActionResult Show(Guid id) { var repository = CurrentAccountDbContext.GetUnitTestTypeRepository(); var unitTestType = repository.GetById(id); var model = new UnitTestTypeEditModel() { Id = unitTestType.Id, DisplayName = unitTestType.DisplayName, SystemName = unitTestType.SystemName, ActualTime = TimeSpanHelper.FromSeconds(unitTestType.ActualTimeSecs), NoSignalColor = ColorStatusSelectorValue.FromColor(unitTestType.NoSignalColor), IsDeleted = unitTestType.IsDeleted, IsSystem = unitTestType.IsSystem }; return(View(model)); }
public ActionResult Edit(Guid id) { var unitTest = GetUnitTestById(id); var model = new UnitTestEditModel() { Id = unitTest.Id, ComponentId = unitTest.Component.Id, Date = unitTest.Bulb.EndDate, DisplayName = unitTest.DisplayName, IsDeleted = unitTest.IsDeleted, Message = unitTest.Bulb.Message, PeriodSeconds = unitTest.PeriodSeconds, ActualTime = TimeSpanHelper.FromSeconds(unitTest.ActualTimeSecs), NoSignalColor = ColorStatusSelectorValue.FromColor(unitTest.NoSignalColor), Status = unitTest.Bulb.Status, UnitTestType = unitTest.Type, UnitTest = unitTest }; return(View(model)); }