private async void LoadItemList() { if (_mainWindowViewModel.ConnectionStatus != DatabaseConnectionStatus.Connected) { _mainWindowViewModel.ShowErrorMessage("出错了", "数据库未连接"); return; } try { var itemList = await DoLoadItemList(); foreach (var item in itemList) { ItemList.Add(item); } EditItemCommand.RaiseCanExecuteChanged(); CopyItemCommand.RaiseCanExecuteChanged(); DeleteItemCommand.RaiseCanExecuteChanged(); } catch (Exception e) { _mainWindowViewModel.ShowErrorMessage("加载出错", e.Message); } }
public async Task <IActionResult> Put(Guid id, EditItemCommand request) { request.Id = id; var result = await _mediator.Send(request); return(Ok(result)); }
/// <summary> /// Исключения: /// System.ArgumentNullException: /// Параметр model имеет значение null. /// </summary> /// <param name="model"></param> public DetailItemViewModel(IItemModelAdapter <DataModelType> model, IDataDetailViewModelCreator <DataModelType, DataDetailViewModelType> viewModelCreator, IItemModelAdapterCreator <DataModelType> itemModelCreator) { if (model == null) { throw new ArgumentNullException("model can't be null"); } if (viewModelCreator == null) { throw new ArgumentNullException("viewModelCreator can't be null"); } if (itemModelCreator == null) { throw new ArgumentNullException("itemModelCreator can't be null"); } _model = model; _model.Updated += OnUpdate; UpdateCommand = new UpdateItemCommand <DataModelType, DataDetailViewModelType>(this); EditCommand = new EditItemCommand <DataModelType, DataDetailViewModelType>(this); SaveCommand = new SaveItemCommand <DataModelType, DataDetailViewModelType>(this); Debug.Assert(_model.DataModel != null); _viewModelCreator = viewModelCreator; _itemModelCreator = itemModelCreator; DataViewModel = _viewModelCreator.CreateDataDetailViewModel(_model.DataModel); }
public void should_have_error_when_GenreId_is_null() { var editItemCommand = new EditItemCommand { Price = new Money() }; _validator.ShouldHaveValidationErrorFor(x => x.GenreId, editItemCommand); }
public void should_have_error_when_GenreId_doesnt_exist() { _mediatorMock .Setup(x => x.Send(It.IsAny <GetGenreCommand>(), CancellationToken.None)) .ReturnsAsync(() => null); var editItemCommand = new EditItemCommand { Price = new Money(), GenreId = Guid.NewGuid() }; _validator.ShouldHaveValidationErrorFor(x => x.GenreId, editItemCommand); }
public ItemPopupViewModel() { isreadonly = true; isreadonly_memo = true; IsCategoryPopup = false; ItemPopupCloseCommandProperty = new ItemPopupCloseCommand(); ItemPopupTitleBarCommandProperty = new ItemPopupTitleBarCommand(); editItemCommandProperty = new EditItemCommand(); editItemMemoCommandProperty = new EditItemMemoCommand(); itemPopupCategoryCommandProperty = new ItemPopupCategoryCommand(); SearchItemPopupCloseProperty = new SearchItemPopupCloseCommand(); }
public async Task <IActionResult> Put(Guid id, EditItemCommand request) { request.Id = id; var result = await _mediator.Send(request); var hateoasResult = new ItemHateoasResponse { Data = result }; await _linksService.AddLinksAsync(hateoasResult); return(Ok(hateoasResult)); }
public ActionResult Edit(ItemViewModel itemViewModel) { if (ModelState.IsValid) { var editItemCommand = new EditItemCommand(); Mapper.CreateMap<ItemViewModel, EditItemCommand>(); Mapper.Map(itemViewModel, editItemCommand); CommandProcessor.Process<EditItemCommand, CommandResult>(editItemCommand, ModelState); if (!ModelState.IsValid) return View(); return this.RedirectToAction(c => c.Index(null, null)); } return View(); }