public async Task <Unit> Handle(Command request, CancellationToken cancellationToken) { var catalogItem = Mapping.Map <Command, CatalogItem>(request); await _catalogItemRepository.AddAsync(catalogItem); return(Unit.Value); }
public async Task <int> Handle(AddCatalogItem request, CancellationToken cancellationToken) { await Validate(request); var catalogItem = new CatalogItem( request.CatalogTypeId, request.CatalogBrandId, request.Description, request.Name, request.Price, request.PictureUri); try { var added = await _catalogItemRepository.AddAsync(catalogItem); return(added.Id); } catch (Exception) { throw new GeneralException($"Failed to add an item"); } }
public async Task AddToCatalogAsync(string ownerId, string productName, string productPictureUrl) { await _catalogItemRepository.AddAsync(ownerId, productName, productPictureUrl); }