public ActionResult Delete(Guid id) { var repository = CurrentAccountDbContext.GetUnitTestRepository(); var unitTest = repository.GetById(id); if (unitTest == null) { throw new UserFriendlyException("Не удалось найти проверку с Id = " + id); } unitTest.IsDeleted = true; CurrentAccountDbContext.SaveChanges(); return(RedirectToAction("Index", "UnitTests", new { unitTestTypeId = unitTest.TypeId })); }
public ActionResult CreateAndCloseDefectForEventType(Guid eventTypeId) { var eventType = GetEventTypeById(eventTypeId); var defectService = CurrentAccountDbContext.GetDefectService(); var user = GetUserById(CurrentUser.Id); var defect = defectService.CreateAndCloseDefectForEventType(CurrentUser.AccountId, eventType, user); CurrentAccountDbContext.SaveChanges(); return(GetSuccessJsonResponse(new { defectId = defect.Id, eventTypeId = eventType.Id })); }
public ActionResult Edit(EditDefectModel model) { var repository = CurrentAccountDbContext.GetDefectRepository(); var defect = repository.GetById(model.Id); if (ModelState.IsValid) { defect.Title = model.Title; defect.Notes = model.Notes; defect.ResponsibleUserId = model.UserId; CurrentAccountDbContext.SaveChanges(); return(RedirectToAction("Show", new { id = model.Id })); } model.DefectCode = defect.GetCode(); return(View(model)); }
public ActionResult Add(AddDefectModel model) { if (!ModelState.IsValid) { return(PartialView(model)); } var service = CurrentAccountDbContext.GetDefectService(); var createUser = GetUserById(CurrentUser.Id); var responsibleUser = GetUserById(model.ResponsibleUserId.Value); service.CreateDefect(CurrentUser.AccountId, model.Title, createUser, responsibleUser, model.Notes); CurrentAccountDbContext.SaveChanges(); return(GetSuccessJsonResponse()); }
public ActionResult ChangeStatusDialogPost(ChangeDefectStatusDialogModel model) { if (model.DefectId == null) { throw new Exception("model.DefectId == null"); } if (model.Status == null) { throw new Exception("model.Status == null"); } var defect = GetDefectById(model.DefectId.Value); var defectService = CurrentAccountDbContext.GetDefectService(); var user = GetUserById(CurrentUser.Id); defectService.ChangeStatus(CurrentUser.AccountId, defect, model.Status.Value, user, model.Comment); CurrentAccountDbContext.SaveChanges(); return(GetSuccessJsonResponse()); }
public ActionResult Delete(DeleteConfirmationSmartModel model) { try { // TODO Удаление подписок нужно делать через Диспетчер var repository = CurrentAccountDbContext.GetSubscriptionRepository(); var subscription = repository.GetById(model.Id); CheckEditingPermissions(subscription); var subscriptionService = new SubscriptionService(DbContext); subscriptionService.Remove(CurrentUser.AccountId, subscription); CurrentAccountDbContext.SaveChanges(); return(GetSuccessJsonResponse()); } catch (Exception exception) { MvcApplication.HandleException(exception); return(GetErrorJsonResponse(exception)); } }
public ActionResult Edit(EditLogModel model) { if (!ModelState.IsValid) { return(PartialView(model)); } var repository = CurrentAccountDbContext.GetLogConfigRepository(); var config = repository.GetByComponentId(model.Id); model.ComponentName = config.Component.DisplayName; config.IsFatalEnabled = model.IsFatalEnabled; config.IsErrorEnabled = model.IsErrorEnabled; config.IsWarningEnabled = model.IsWarningEnabled; config.IsInfoEnabled = model.IsInfoEnabled; config.IsDebugEnabled = model.IsDebugEnabled; config.IsTraceEnabled = model.IsTraceEnabled; config.LastUpdateDate = Now(); CurrentAccountDbContext.SaveChanges(); return(GetSuccessJsonResponse()); }
public ActionResult CreateDefectDialog(Guid?eventTypeId, Guid?userId, string comment) { if (eventTypeId == null) { throw new Exception("eventTypeId == null"); } if (userId == null) { throw new Exception("userId == null"); } var eventType = GetEventTypeById(eventTypeId.Value); var defectService = CurrentAccountDbContext.GetDefectService(); var createUser = GetUserById(CurrentUser.Id); var responsibleUser = GetUserById(userId.Value); var defect = defectService.GetOrCreateDefectForEventType(CurrentUser.AccountId, eventType, createUser, responsibleUser, comment); CurrentAccountDbContext.SaveChanges(); return(GetSuccessJsonResponse(new { defectId = defect.Id })); }
public ActionResult Edit(EditModel model) { try { model.Validate(); } catch (UserFriendlyException exception) { ModelState.AddModelError(string.Empty, exception.Message); } if (!ModelState.IsValid) { return(View(model)); } model.SaveCommonSettings(); model.SaveRule(); CurrentAccountDbContext.SaveChanges(); return(RedirectToAction("ResultDetails", "UnitTests", new { id = model.Id })); }
public ActionResult Index( ColorStatusSelectorValue color, Guid?componentTypeId = null, string search = null, string save = null) { if (save == "1") { var service = CurrentAccountDbContext.GetUserSettingService(); service.ShowComponentsAsList(CurrentUser.Id, false); CurrentAccountDbContext.SaveChanges(); return(RedirectToAction("Index", new { color = color.HasValue ? color : null, componentTypeId, search })); } var model = new ComponentsTreeModel() { ComponentTypeId = componentTypeId, Color = color, Search = search }; return(View(model)); }
public UnitTest SaveSimpleCheck(T model) { var dispatcher = GetDispatcherClient(); var unitTestDisplayName = GetUnitTestDisplayName(model); if (model.Id.HasValue) { var unitTest = GetUnitTestById(model.Id.Value); var updateData = new UpdateUnitTestRequestData() { ComponentId = unitTest.ComponentId, DisplayName = unitTestDisplayName, PeriodSeconds = TimeSpanHelper.GetSeconds(model.Period), UnitTestId = unitTest.Id, ErrorColor = unitTest.ErrorColor, NoSignalColor = ObjectColor.Gray, SystemName = unitTest.SystemName, SimpleMode = true }; dispatcher.UpdateUnitTest(CurrentUser.AccountId, updateData).Check(); // Зем: название компонента решили не менять, чтобы не было неожиданных сюрпризов, // меняешь проверку, а меняется компонент, если нужно изменить название компонента, // пусть пользователь сделает это явно вручную // Обновим параметры SetUnitTestParams(unitTest, model); CurrentAccountDbContext.SaveChanges(); this.SetTempMessage(TempMessageType.Success, string.Format("Обновлена проверка <a href='{1}' class='alert-link'>{0}</a>", unitTest.DisplayName, Url.Action("Edit", "Checks", new { id = unitTest.Id }))); return(unitTest); } else // создание проверки { // Создаём компонент только если его ещё нет ComponentInfo component; if (!model.ComponentId.HasValue) { // Создадим папку для компонента var componentRepository = CurrentAccountDbContext.GetComponentRepository(); var root = componentRepository.GetRoot(); var createFolderResponse = dispatcher.GetOrCreateComponent(CurrentUser.AccountId, new GetOrCreateComponentRequestData() { SystemName = GetFolderSystemName(model), DisplayName = GetFolderDisplayName(model), TypeId = SystemComponentTypes.Folder.Id, ParentComponentId = root.Id }); if (!createFolderResponse.Success) { throw new UserFriendlyException("Ошибка создания папки для проверки: " + createFolderResponse.ErrorMessage); } var folder = createFolderResponse.Data.Component; // Создадим тип компонента var createComponentTypeResponse = dispatcher.GetOrCreateComponentType(CurrentUser.AccountId, new GetOrCreateComponentTypeRequestData() { SystemName = GetTypeSystemName(model), DisplayName = GetTypeDisplayName(model) }); if (!createComponentTypeResponse.Success) { throw new UserFriendlyException("Ошибка создания типа компонента для проверки: " + createComponentTypeResponse.ErrorMessage); } var componentType = createComponentTypeResponse.Data; // Создадим компонент var componentId = Guid.NewGuid(); var createComponentResponse = dispatcher.GetOrCreateComponent(CurrentUser.AccountId, new GetOrCreateComponentRequestData() { NewId = componentId, SystemName = GetComponentSystemName(componentId), DisplayName = GetComponentDisplayName(model), TypeId = componentType.Id, ParentComponentId = folder.Id }); if (!createComponentResponse.Success) { throw new UserFriendlyException("Ошибка создания компонента для проверки: " + createComponentResponse.ErrorMessage); } component = createComponentResponse.Data.Component; } else { component = dispatcher.GetComponentById(CurrentUser.AccountId, model.ComponentId.Value).Data; } // Создадим проверку var unitTestId = Guid.NewGuid(); var createUnitTestData = new GetOrCreateUnitTestRequestData() { ActualTimeSecs = null, ComponentId = component.Id, DisplayName = unitTestDisplayName, ErrorColor = UnitTestResult.Alarm, NewId = unitTestId, SimpleMode = true, NoSignalColor = ObjectColor.Gray, PeriodSeconds = TimeSpanHelper.GetSeconds(model.Period), SystemName = UnitTestHelper.GetDynamicSystemName(unitTestId), UnitTestTypeId = GetUnitTestTypeId() }; dispatcher.GetOrCreateUnitTest(CurrentUser.AccountId, createUnitTestData).Check(); var unitTest = GetUnitTestById(unitTestId); SetUnitTestParams(unitTest, model); CurrentAccountDbContext.SaveChanges(); this.SetTempMessage(TempMessageType.Success, string.Format("Добавлена проверка <a href='{1}' class='alert-link'>{0}</a>", unitTest.DisplayName, Url.Action("Edit", "Checks", new { id = unitTest.Id }))); return(unitTest); } }