public ActionResult Delete(DeleteConfirmationModel model) { if (!ModelState.IsValid) { return(View("~/Views/Shared/Dialogs/DeleteConfirmation.cshtml", model)); } var repository = CurrentAccountDbContext.GetUnitTestTypeRepository(); var unitTestType = repository.GetById(Guid.Parse(model.Id)); CheckDeletingPermissions(unitTestType); var client = GetDispatcherClient(); var response = client.DeleteUnitTestType(CurrentUser.AccountId, new DeleteUnitTestTypeRequestData() { UnitTestTypeId = unitTestType.Id }); if (!response.Success) { throw new UserFriendlyException(response.ErrorMessage); } this.SetTempMessage(TempMessageType.Success, "Тип проверки удалён"); return(RedirectToAction("Index")); }
public ActionResult Edit(UnitTestTypeEditModel model) { if (!ModelState.IsValid) { return(View(model)); } var repository = CurrentAccountDbContext.GetUnitTestTypeRepository(); var unitTestType = repository.GetById(model.Id); CheckEditingPermissions(unitTestType); var client = GetDispatcherClient(); var response = client.UpdateUnitTestType(CurrentUser.AccountId, new UpdateUnitTestTypeRequestData() { UnitTestTypeId = unitTestType.Id, DisplayName = model.DisplayName, SystemName = model.SystemName, ActualTimeSecs = TimeSpanHelper.GetSeconds(model.ActualTime), NoSignalColor = model.NoSignalColor.GetSelectedOne() }); response.Check(); return(RedirectToAction("Show", new { id = model.Id })); }
public ActionResult Add(UnitTestAddModel model) { if (!ModelState.IsValid) { return(View(model)); } var componentRepository = CurrentAccountDbContext.GetComponentRepository(); var component = componentRepository.GetById(model.ComponentId.Value); var unitTestTypeRepository = CurrentAccountDbContext.GetUnitTestTypeRepository(); var unitTestType = unitTestTypeRepository.GetById(model.UnitTestTypeId); var client = GetDispatcherClient(); var data = new GetOrCreateUnitTestRequestData() { ComponentId = component.Id, UnitTestTypeId = unitTestType.Id, DisplayName = model.DisplayName, SystemName = model.DisplayName }; var response = client.GetOrCreateUnitTest(CurrentUser.AccountId, data); var unitTest = response.Data; this.SetTempMessage(TempMessageType.Success, string.Format("Добавлена проверка <a href='{1}' class='alert-link'>{0}</a>", unitTest.DisplayName, Url.Action("ResultDetails", new { id = unitTest.Id }))); return(RedirectToAction("Index")); }
public JsonResult CheckSystemName(UnitTestTypeEditModel model) { var repository = CurrentAccountDbContext.GetUnitTestTypeRepository(); var unitTestType = repository.GetOneOrNullBySystemName(model.SystemName); if (unitTestType != null && (model.Id == Guid.Empty || model.Id != unitTestType.Id)) { return(Json("Тип проверки с таким системным именем уже существует", JsonRequestBehavior.AllowGet)); } return(Json(true, JsonRequestBehavior.AllowGet)); }
public ActionResult Index(string search = null) { var repository = CurrentAccountDbContext.GetUnitTestTypeRepository(); var items = repository .QueryAllForGui(search) .OrderBy(t => t.IsSystem) .ThenBy(t => t.DisplayName); var model = new UnitTestTypeListModel() { Search = search, Items = items }; return(View(model)); }
public ActionResult Delete(Guid id) { var repository = CurrentAccountDbContext.GetUnitTestTypeRepository(); var unitTestType = repository.GetById(id); CheckDeletingPermissions(unitTestType); var model = new DeleteConfirmationModel() { Id = id.ToString(), Title = "Удаление типа юнит-теста", ModalMode = Request.IsAjaxRequest(), Message = "Вы действительно хотите удалить этот тип проверки?", ReturnUrl = Url.Action("Index") }; return(View("~/Views/Shared/Dialogs/DeleteConfirmation.cshtml", 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)); }