public override async void OnNavigatingTo(INavigationParameters parameters) { await DialogService.PopAsync(); if (parameters.ContainsKey("color")) { var color = parameters["color"] as NamedColor; ConfirmColorCommand.Execute(color); } else if (parameters.ContainsKey("categoryID")) { IsNewCategory = false; var categoryID = parameters["categoryID"] as string; GetCategoryCommand.Execute(categoryID); } else { Category = new CategoryModel { CategoryName = "", }; SavedCategory = new CategoryModel { CategoryName = "", }; States = new ObservableCollection <StateModel>(); SavedStates = new ObservableCollection <StateModel>(); IsNewCategory = true; Title = "New category"; IsUpdated = true; } }
public async override Task <CategoryDto> Handle(GetCategoryCommand request, CancellationToken cancellationToken) { Entity = repo.Find(request.ID); EntityDto = mapper.Map <Category, CategoryDto>(Entity); return(EntityDto); }
public async Task <IActionResult> GetCategory([FromRoute] int id) { var command = new GetCategoryCommand() { Id = id }; return(Ok(await mediator.Send(command))); }
public CategoryManager(CommerceCommander commander, GetCategoryCommand getCategoryCommand, CreateCategoryCommand createCategoryCommand, AssociateCategoryToParentCommand associateCategoryToParentCommand, FindEntityCommand findEntityCommand, CreateRelationshipPipeline createRelationshipPipeline, AddEntityVersionCommand addEntityVersionCommand) { this._commander = commander; this._getCategoryCommand = getCategoryCommand; this._createCategoryCommand = createCategoryCommand; this._associateCategoryToParentCommand = associateCategoryToParentCommand; this._findEntityCommand = findEntityCommand; this._createRelationshipPipeline = createRelationshipPipeline; this._addEntityVersionCommand = addEntityVersionCommand; }
public async Task ShouldGetCategoryQuery() { // Arrange var getCategoryCommand = new GetCategoryCommand(7, WorkContext.WorkingLanguageId); // Act var category = await _getCategoryQuery.Query(getCategoryCommand); // Assert Assert.IsNotNull(category); }
private async Task <IActionResult> CreateCategory(GetCategoryCommand command) { var categoryDtoResult = await QueryProcessor.GetQueryHandler <GetCategoryCommand, CategoryDto>(command); if (categoryDtoResult.Failure) { return(BadRequest(categoryDtoResult)); } var categoryDto = categoryDtoResult.Object; return(Ok(categoryDto)); }
public async Task ShouldGetSubCategory() { // Arrange var listCategoriesCommand = new ListCategoriesCommand(1, WorkContext.WorkingLanguageId, true); var categoryId = (await _listCategoriesQuery.Query(listCategoriesCommand)).Items .FirstOrDefault(o => o.Route.AngularComponent.Code == AngularComponents.SubCategoryComponent).Id; var getCategoryCommand = new GetCategoryCommand(categoryId, WorkContext.WorkingLanguageId); // Act var result = await _getCategoryQueryHandler.Handle(getCategoryCommand); // Assert Assert.IsNotNull(result?.Object); }
public async Task ShouldGetCategory() { // Arrange var listCategoriesCommand = new ListCategoriesCommand(1, WorkContext.WorkingLanguageId, true); var categoryId = (await _listCategoriesQuery.Query(listCategoriesCommand)).Items .FirstOrDefault(o => o.Route.AngularComponent.Code == AngularComponents.ProductCategoryComponent).Id; var getCategoryCommand = new GetCategoryCommand(7, WorkContext.WorkingLanguageId); var listProductsByCategoryCommand = new ListProductsByCategoryCommand(7, WorkContext.WorkingLanguageId, pageIndex: 1, pageSize: 24); // Act var categoryDto = (await _getCategoryQueryHandler.Handle(getCategoryCommand)).Object; var productsDto = (await _listProductsByCategoryQueryHandler.Handle(listProductsByCategoryCommand)); // Assert Assert.IsNotNull(categoryDto); Assert.IsNotNull(productsDto); }
public async Task Category_Get() { var connection = TestHelper.GetConnection(); var options = TestHelper.GetMockDBOptions(connection); try { using (var context = new AppcentTodoContext(options)) { var service = new GetCategoryCommandHandler(context); var command = new GetCategoryCommand(); command.Data = new GetCategoryRequest { CategoryId = 1, UserName = "******" }; var result = await service.Execute(command); Assert.True(result.Result.IsSuccess); if (result.GetType().IsAssignableTo(typeof(GetCategoryResponse))) { var getCategoryRes = (GetCategoryResponse)result; Assert.NotNull(getCategoryRes.CategoryObj); } command.Data = new GetCategoryRequest { CategoryId = 0, UserName = "******" }; result = await service.Execute(command); Assert.True(result.Result.IsSuccess); if (result.GetType().IsAssignableTo(typeof(GetCategoryResponse))) { var getCategoryRes = (GetCategoryResponse)result; Assert.NotNull(getCategoryRes.Categories); Assert.NotEmpty(getCategoryRes.Categories); } } } finally { connection.Close(); } }
public async Task <ActionResult> GetCategory([FromBody] GetCategoryDto viewRequest) { if (!TryValidateModel(viewRequest)) { return(BadRequest(ValidationHelper.GetModelErrors(ModelState))); } var request = this._mapper.Map <GetCategoryRequest>(viewRequest); request.UserName = HttpContext.User.Identity.Name; var command = new GetCategoryCommand { Data = request }; return(await Go(command)); }
/// <summary> /// c'tor /// </summary> /// <param name="createCategoryCommand">createCategoryCommand</param> /// <param name="associateCategoryToParentCommand">associateCategoryToParentCommand</param> /// <param name="getCategoryCommand">Get Category Command</param> /// <param name="editCategoryCommand">Edit Category Command</param> /// <param name="deleteRelationshipCommand">Delete Relationship Command</param> /// <param name="findEntitiesInListCommand">Find entities in List Command</param> /// <param name="associatedItemRetrievalService">associatedItemRetrievalService</param> public CategoryImporter( CreateCategoryCommand createCategoryCommand, AssociateCategoryToParentCommand associateCategoryToParentCommand, GetCategoryCommand getCategoryCommand, EditCategoryCommand editCategoryCommand, DeleteRelationshipCommand deleteRelationshipCommand, FindEntitiesInListCommand findEntitiesInListCommand, IAssociatedItemRetrievalService associatedItemRetrievalService) { _createCategoryCommand = createCategoryCommand; _associateCategoryToParentCommand = associateCategoryToParentCommand; _getCategoryCommand = getCategoryCommand; _editCategoryCommand = editCategoryCommand; _deleteRelationshipCommand = deleteRelationshipCommand; _findEntitiesInListCommand = findEntitiesInListCommand; _associatedItemRetrievalService = associatedItemRetrievalService; }
public async Task <IActionResult> Create(string url) { url = url?.TrimStart('/') ?? ""; var urlPath = url.Split('?').First(); if (Regex.IsMatch(urlPath.Split('/').Last(), @"^\d+$")) { urlPath = urlPath.Substring(0, urlPath.LastIndexOf("/")); } var routeDtoResult = await QueryProcessor.GetQueryHandler <GetRouteByUrlCommand, RouteDto>(new GetRouteByUrlCommand(urlPath, WorkContext.WorkingLanguageId)); if (routeDtoResult.Failure) { return(BadRequest(routeDtoResult.ErrorMessages)); } var currentRouteDto = routeDtoResult.Object; if (currentRouteDto == null) { // TODO: 404 return(NotFound()); } if (currentRouteDto.AngularComponent != AngularComponents.ProductComponent) { var getCategoryCommand = new GetCategoryCommand(currentRouteDto.ItemId.Value, WorkContext.WorkingLanguageId); return(await CreateCategory(getCategoryCommand)); } else { var getProductCommand = new GetProductCommand(currentRouteDto.ItemId.Value, WorkContext.WorkingLanguageId); return(await CreateProduct(getProductCommand)); } }
public CategoryPathResolver(SitecoreConnectionManager manager, GetCategoryCommand getCategoryCommand) { this.manager = manager; this.getCategoryCommand = getCategoryCommand; }
public CategoryOrderLinesResolver(GetCategoryCommand getCategoryCommand, OrderResolver orderResolver) { this.getCategoryCommand = getCategoryCommand; this.orderResolver = orderResolver; }
public ExtendCategorySearchResultBlock(GetCategoryCommand getCommand, CategoryPathResolver categoryPathResolver) { _getCommand = getCommand; this.categoryPathResolver = categoryPathResolver; }
public CategoryCartLinesResolver(GetCategoryCommand getCategoryCommand) { this.getCategoryCommand = getCategoryCommand; }